1
\$\begingroup\$

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?

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

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);
}
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .