To create a Gizmo to show the selected object in the Scene window, 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.position, radius - 0.1f);
Gizmos.color = Color.green;
Gizmos.DrawWireSphere(transform.position, radius - 0.2f);
}
}
- Make lots of duplicates of the 3D Cube, distributing them randomly around the scene.
- When you select one cube in the Hierarchy window...