Using a gizmo to show the currently selected object in the Scene panel
Gizmos are visual aids that are provided to game designers in the Scene panel. In this recipe, we’ll highlight the GameObject that is currently selected in the Hierarchy panel in the Scene panel.
Figure 19.2: Wireframe spheres around the selected GameObject
How to do it...
To create a gizmo to show the selected object in the Scene panel, follow these steps:
- Create a new Unity 3D project.
- Create a 3D Cube by going to Create | 3D Object | Cube.
- Create a C# script class called
GizmoHighlightSelected
and add an instance object as a component to the 3D Cube:using UnityEngine; public class GizmoHighlightSelected : MonoBehaviour { public float radius = 5.0f; void OnDrawGizmosSelected() { Gizmos.color = Color.red; Gizmos.DrawWireSphere(transform.position, radius); Gizmos.color = Color.yellow; Gizmos.DrawWireSphere(transform...