Drawing to scene view from EditorWindow?


I'm starting to learn Unity editor extension programming, but there seems to be something very elementary that I'm missing. I want to visualize a point in the scene view from an editor extension that's an EditorWindow. Basically it's an extension that will parse through some external data with coordinates and overlay them on the scene view for designers to see. Ideally I would then add various setting to the editor to color-code and filter the shown data among other things.

Because of the lack of documentation (that I could understand, anyway) I'm not sure what tools are available to me. I would like to use color coded spheres such as gizmos, I don't know how to access them from an extension. Handles also seem to require the OnSceneGUI that is not available to an EditorWindow. Debug.DrawLine and DrawRay both work but it seems like a hack and they can't visualize points.

I would like to avoid generating tons of dummy GameObjects to represent the points, because it would then clutter the scene hierarchy and they would be a pain to manage.

Any helpful pointers would be greatly appreciated!

Hi there, try to check the method using on iTween Path, that’s a good starting point to learn how to drive helpers in the scene editor.

I know its fairly late to answer the question; but just for the records…

How to draw on scene from CustomEditor

The way I did it was to write a Custom Editor, and a custom Inspector for my component/object.

My editor doesn’t know about any inspector, and only exposes a bunch of delegates that it will call when it finds something interesting.
It picks up values only from your object, and writes values to it.

The custom inspector on the other hand will know about the existence of the custom editor, and will cache this editor in the OnEnable(). In this same function, the inspector will register to the delegates of the custom editor, and handle related sceneView changes when those delegates are called. [Remember to unregister from the delegates in OnDisable()]

Whenever your inspector needs to update something in the editor, it updates the object and then triggers a repaint/refresh on the editor, which will force the editor to get fresh values and update accordingly.

Working with temporary objects created from script
Editor and Temporary objects