I have a script “Monkey” and a custom editor for it “MonkeyEditor”. OnInspectorGUI in MonkeyEditor runs constantly when the object with Monkey attached is selected. Cool.
But I want functions for when the MonkeyEditor starts up and exits so that I can start and stop some sound effects. (The script manages making monkey sounds during gameplay, so I would like the custom editor to give feedback on the pitch you can edit. So drag the slider and it changes dynamically.)
You’re referring to an in-game editor right? Not some Unity Editor GUI scripting thing?
Assuming that this is the in game UnityGUI system, I would recommend putting the GUI onto it’s own GameObject so that you can use the Start() or Awake() functions to do what you want.
OnInspectorGUI() and CustomEditors are NOT supported in the current version of Unity and will cause problems if you don’t know exactly what you are doing from the start, and even then this interface is likely to change.