官术网_书友最值得收藏!

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.

Overview

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

Overview

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:

Overview

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:

Defining the chapter goals
主站蜘蛛池模板: 玉山县| 大竹县| 清水河县| 隆回县| 册亨县| 岳普湖县| 娄烦县| 汉阴县| 仪陇县| 普兰店市| 怀远县| 临朐县| 马鞍山市| 将乐县| 布尔津县| 香格里拉县| 田林县| 永吉县| 华阴市| 云安县| 芜湖市| 鹤山市| 麦盖提县| 新乡市| 佛山市| 泾源县| 莱阳市| 西和县| 沅江市| 西城区| 揭阳市| 赫章县| 娄烦县| 沙河市| 寿阳县| 宝丰县| 河间市| 巴彦淖尔市| 桑日县| 华亭县| 普兰县|