Sorry for the very broad title but I got a couple of things that I don’t know if it is possible.
- Is it possible to prevent the removal from an object in the hierarchy window?
- Is it possible to before starting the game in editor more, add/update/remove things in the hierarchy?
- Is it possible when creating a new scene to alter the hierarchy after the scene is created?
And if some of these points is true, then can you point me in the right direction? I know that I have to do some editor scripts but I’m not so sure that the editor can let me do this. I’ve failed to find anything
Note, anything in the hierarchy window are just objects that are in the scene. So you add/remove them based on creating/destroying gameobjects per usual.
As for the scenarios you’re describing, technically speaking… yes. But I will admit the API for dealing with editor events isn’t well documented and is scattered around.
The main hooks are:
This has several callbacks for various events
The Event.current property is the current event. This can be used during ‘OnGUI’ and a handful of other methods (like those callbacks in EditorApplication) to get information about the current event going on that gui pass. ‘OnGUI’ is called anytime the gui may need to change, and can happen multiple times in a single frame, or not get called for long periods of time. It occurs on things like mouse down, and objects deleting, and other stuff. I honeslty don’t know the whole list of events, and they are often identified by a magic string in the ‘Event.commandName’ property… very annoying.
There’s a few other hooks here and there.
Honestly though, it’s just one of those things that you have to just dig into and start tinkering with.
If ANYONE could come along and supply any easy to navigate documentation on this, I’d be MUCH appreciated. The unity documentation is scattered and hard to locate, especially if you don’t know what you’re looking for. It mostly comes in tutorial form, which drives me bonkers… (I am not a fan of tutorial form documentation, it’s good for examples, but crap for researching the API).
1 Like