- Extending Unity with Editor Scripting
- Angelo Tadres
- 306字
- 2021-07-16 19:59:19
Overview
In Unity, a gizmo is a visual aid rendered in Unity's Scene View to help us in the development process. Several components in Unity use gizmos to tell the developers where in the 3D world these are located.
Take a look at the following screenshot. The two icons, the movie camera and the light bulb, are gizmos that indicate the game object position of the camera and the point light components, respectively.

You can do the same with a specific game object if you click on the cube icon in their inspector pane:

Here you have three options to choose:
- Use a label
- Use a built-in icon
- Use a custom icon made with any image located inside your project
You will see the following three results, respectively, in the Scene View:

Any of these gizmos will be attached to the game object and will persist in the scene and in any prefab containing this game object.
All these examples use the Unity editor to do the required setup, but there is an additional way in which gizmos can be created, allowing greater flexibility due to the use of parameters related to our game logic. This is achieved through code using the Gizmos class.
Defining the chapter goals
In this chapter, we will start exploring the many alternatives we have for adding gizmos to Unity and then finish with the implementation of a visual grid for positioning the level piece prefabs, setting the boundaries for our level in this way.
The goals here are:
- Exploring how to add gizmos through code
- Defining the size of the level in terms of columns and rows
- Rendering a grid using gizmos based on the size of the level
- Implementing a snap to grid feature using the level piece prefabs
The final result that we will achieve looks like this:

- WildFly:New Features
- 計算思維與算法入門
- 數(shù)據(jù)結(jié)構(gòu)簡明教程(第2版)微課版
- VMware vSphere 6.7虛擬化架構(gòu)實戰(zhàn)指南
- Swift 3 New Features
- 高級C/C++編譯技術(shù)(典藏版)
- Getting Started with Python Data Analysis
- The HTML and CSS Workshop
- Flutter跨平臺開發(fā)入門與實戰(zhàn)
- 大話Java:程序設(shè)計從入門到精通
- Python 3.7從入門到精通(視頻教學(xué)版)
- 機器學(xué)習(xí)微積分一本通(Python版)
- Ionic3與CodePush初探:支持跨平臺與熱更新的App開發(fā)技術(shù)
- PHP 7 Programming Blueprints
- 零基礎(chǔ)C語言學(xué)習(xí)筆記