Editor-only circular contour around prefab instances

I have a prefab with radius setting, which programatically controls circular area with some stuff. I want instances of this prefab to display a circle with this radius in editor for convenience. Instead of radius setting I can attach circle collider to get visual border and then read its radius at runtime, but this seems code smell (I will need to programmatically remove/disable it etc), and resource waste. Are there some good practices to implement things like this?

Hi, there is something very convenient to do this: OnDrawGizmos() and OnDrawGizmosSelected(), check Monobehavior documentation.

In those callbacks, you can use Gizmos.DrawLine (check other Gizmos. methods) to draw a circle around the object.

You can also use “#if UNITY_EDITOR” around this code so it is only included in the editor (not sure those are conditionally compiled).

Found an answer myself. That’s actually quite easy. There is some “Gizmos” stuff for things like that, and it’s possible to just overload OnDrawGizmos (in a script attached to prefab) and use built-in function to draw circle in editor:

private void OnDrawGizmos()
    UnityEditor.Handles.color = Color.yellow;
    UnityEditor.Handles.DrawWireDisc(transform.position, Vector3.back, Radius);