While trying to make a (rather complex) editor for a component, I decided that, instead of trying to cram everything into a custom inspector, to just make a simple one that creates a custom EditorWindow, like this:
And use this window to edit the target. However, if the target is deleted and the window is still open, it should close itself. For that purpose I wrote the following at the start of the window's OnGUI():
However, if I test it out by simply not setting the target, I get the following errors:
And the slightly more intuitive
Am I doing something wrong? This seems to be all fine according to the Reference and the examples they've given.
Move that piece of code to the window's update function and you should be fine.
answered Jul 10 '12 at 06:31 PM
What happens is that when target is not set, the first OnGUI call is used to close the window, which was generated in the same iteration.
You basically need to change your window condition into something like:
answered Jul 10 '12 at 07:32 AM
The Arc Games