Closed Eregerog closed 5 years ago
Going to use EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
instead.
@Eregerog is there any reason not to use Undo.RegisterCreatedObjectUndo
instead?
Those are two different things: Registering an undo has to be called before the modification is made and only allows "stores" the objects current state which can be re-applied by undoing the change. Mark(AllScenes)Dirty in general tells the editor that an asset has changed, and enables the option to save it.
Going to use
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
instead.
The things is, there may be multiple scenes active, and you don't know in which active scene the singleton is. Therefore simply mark all scenes dirty
If you want to use a lazy singeton in edit time and a new instance has to be created, the scene is modified because a new gameobject and component is added. To my knowledge, the scene has then be marked dirty with
This would allow lazy singletons to be used during edit time