Search Unity

EditorSceneManager.MarkSceneDirty doesn't seem to work as intended.

Discussion in 'Editor & General Support' started by Razieln64, May 3, 2016.

  1. Razieln64

    Razieln64

    Joined:
    May 3, 2008
    Posts:
    129
    Hi,

    I am changing some of my inspector scripts to not use EditorUtility.SetDirty to update the scene as explained here : http://docs.unity3d.com/ScriptReference/EditorUtility.SetDirty.html .

    What I basically use this for is to make previews of things in the scene for easily changing parameters and seeing how the result would look.

    What I do is use an editor that creates game objects in the scene that are hidden and not saved i.e. HideFlags.HideAndDontSave.

    So I use EditorUtility.CreateGameObjectWithHideFlags and add a component that is linked to a prefab and renders it in the scene without instantiating it.

    My issue is that since EditorUtility.SetDirty has been modified to not work as intended, my created game object doesn't appear in the scene unless I force a scene refresh by going out of focus (i.e. opening the console). I have been calling EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()) every time I move my generated game object and also after creating it an it doesn't do anything. I don't want to save this game object so I don't want to set the scene dirty, only tell it to redraw itself.

    I have the same issue when trying to delete my created game object when my editor is destroyed. The object remains visible in the scene even if I called DestroyImmediate.

    Is there a solution fo this? Thank you