Can I put the 'OnDrawGizmos' code in the CustomEditor?
Since the Editor for my behavoir doesn't inherit from MonoBehvior, it doesn't have an OnDrawGizmos
or OnDrawGizmosSelected
method.
I would like to keep all the editor and debug code in the Editor, first of all to keep things organized, but also so it doesn't get compiled when I build the final release. Is there any way to respond to "GizmosSelected" from the Editor instead of the MonoBehavior, without the behavior needing to keep a reference to the editor all the time?
Answer by slavo · Nov 09, 2016 at 09:13 AM
You can use Draw Gizmo attribute. https://docs.unity3d.com/ScriptReference/DrawGizmo.html
That is cool, but how would you go about getting reference to the Editor object? (seeing as you'd want access to current instance fields and such from the Editor object).
I don't want to touch the original GameObject script so I don't want to add edit specific things to it, that's the purpose of an editor, no?