Get notified in edit time when Objects are deleted/added to scene
Hello. I am making a genreric cache to store there all current Scene's objects grouped by there type. So i want to know when objects are added/deleted from scene. P.s i work in edit time only. Is there such an event ready to use?
Answer by MAGTAR · Apr 25, 2020 at 02:34 PM
Found solution. EditorApplication.hierarchyChanged event triggers every time hierarchy changes. Includes add/delete. Note that the event is not raised immediately in response to these actions, but rather during the next update of the editor application. So we a are sure that all actions have already been executed.
Answer by aka3eka · Apr 25, 2020 at 01:43 PM
Have you tried to use Undo.postprocessModifications and Undo.willFlushUndoRecord events?
I tried this, but events you suggested trigger before real action happens. So first my logic will be executed, and only after that delete/add will happen.