- Home /
Unity Editor Scripts: GameObject Added / Removed Event?
Does Unity provide an editor script event for GameObjects being added or removed from the scene/hierarchy? I've been looking through the Editor Classes and haven't found anything that does what I want.
I want to detect when the user adds/removes any GameObject to/from the scene and handle it in an editor script.
I feel like this question is still relevant and hasn't been answered. Unity should really include this type of callback. I want to be able to keep a list of selected GameObjects and assets and get notified when one of them is removed without having to check for null every update or whenever different changed happen (this also gets ugly when I think about undo).
Answer by echo17 · Mar 27, 2012 at 06:34 PM
check out
EditorApplication.hierarchyWindowChanged
EditorApplication.projectWindowChanged
There isn't much documentation on these, so have at look at this forum thread:
Forum - EditorApplication.hierarchyWindowChanged
Basically, you are assigning a delegate somewhere in your editor code that fires off when either the hierarchy or project windows change.