How can I use the Handles class in an editor window to show a Vector3 point in the scene view?
I simply want to be able to enter co-ordinates and have a handle appear there.
I've got this so far:
But it doesn't work, and looking through the forums and documentation hasn't helped - examples in the docs are pretty sparse with the Handles class...
asked Jun 11 '10 at 07:12 PM
Old question, so you've probably figured it out already, but anyway ...
EditorWindow doesn't have an OnSceneGUI method, so your code above will never get called. You can do what you want in a custom Editor, but not an EditorWindow. For an Editor, the OnSceneGUI method lets you draw into the scene view, which is where the Handles class becomes useful.
Typically the OnSceneGUI method would be used to draw things in the scene relative to the target object of the Editor (the component being edited), but there's nothing to stop your Editor from having its own member variables and drawing whatever it feels like.
Note that Editor.OnSceneGUI will only be called when the editor is active in the Inspector, which may not be what you're looking for.
MonoBehaviour.OnDrawGizmos may be a simpler solution to what you're trying to do. You could have a component with an array of Vecto3's, and have its OnDrawGizmos method draw a handle for each of the vectors.
answered Jan 05 '11 at 04:05 PM