- Home /
Am I over-engineering my editorscript?
Hey guys. So I wanted to make a level builder, by having an editor-window which would allow you to place objects with snapping to grid.
EditorWindow does not allow any control of things in the viewport, as OnSceneGUI isn't called, so to get around this I just instantiate an object when you press a button, and then assign a script to it.
That script has a custom-editor-script associated with it, that then finds the position with snapping and all, from mousep osition, and calls a function on the target-script. On mousedown, it destroys the target-script.
To let the editorwindow know when creation is complete, I wanted to assign a reference back to the editor-window, to the newly made script, but Unity wouldn't allow this. Instead I set up an event in the target-script, which is then listened to by the editor-window.
I can not trigger the event from outside the target-script, though, so the custom-editor for the target-script could not call it directly, so in the target-script, I have a function, doing nothing but calling the event.
All this messing around feels ver "Rube Goldberg", and is probably not good code practice, so I just wanted to know if anyone have any ideas on how to does this more elegantly.
Any element of it, really.. Thanks
Couldn't you use the Selection class to modify the selected GameObject from the EditorWindow?
Your answer
Follow this Question
Related Questions
How do I wait until after AssetDatabase creates an assets before carrying out another function ? 0 Answers
Find instance of EditorWindow without creating new one? 2 Answers
Weird bug when dragging object onto EditorGUILayout.ObjectField 0 Answers
Dock Game Window In Code? 1 Answer
why I Cant Add Multiple Objects to the "Object Field" in Editor Window? 3 Answers