- Home /
How Mark Prefab Dirty?
I open prebab in prefab mode.
Then I change some properties of component via script
Unity Editor doesn't understabd that prefab was changed.
I tried EditorUtility.SetDirty for component and game object. But it doesn't work In previos versions I used EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene()); But now we have "Prefab Mode" for prefab edit
Answer by KissMeQuickYukimoto · Feb 21, 2019 at 05:02 AM
var prefabStage = UnityEditor.Experimental.SceneManagement.PrefabStageUtility.GetCurrentPrefabStage();
if (prefabStage != null) {
EditorSceneManager.MarkSceneDirty(prefabStage.scene);
}
This doesn't work for me. The change in the prefab is still lost after restart since there in no current PrefabStage. Strange enough Unity saves the scene nonetheless..
And the code should be ... UnityEditor.Scene$$anonymous$$anagement.EditorScene$$anonymous$$anager.$$anonymous$$arkSceneDirty(prefabStage.scene); ...
Your answer
Follow this Question
Related Questions
How to modify prefab permanently via script. 0 Answers
Trying to have my Editor Script save the changed settings when I hit Play 0 Answers
How can I link a GameObject instance to a script variable in a Prefab using the editor? 1 Answer
Unity 5 C#, having a script show up in a path in the Editor 1 Answer
Standard Assets disappears in somes Android Phones 0 Answers