How do I draw gizmos only when the is object is being inspected?

I tried making a flag in my object that my Editor sets in OnInspectorGUI to let it know it's being inspected, but couldn't find a good way to let it know when it stops being inspected. Any ideas?

1 Answer

1

To draw a gizmo only when selected, use OnDrawGizmosSelected. If you want to check what's selected in general, use e.g. Selection.activeGameObject, though this only works in an editor script.

Ah! I didn't pay much attention to Selection since you can select multiple objects and I only wanted the one to render its gizmos. Thanks for making me aware of the activeGameObject!

–