I’m trying to edit my scenes and prefabs on save. The scene works great, as long as I don’t try to edit prefabs.
I wrote a post processor to go over the scene and change the things I need. For simplicity I give you a very basic example to reproduce:
[InitializeOnLoad]
public static class SceneSavePostprocessor
{
static SceneSavePostprocessor()
{
EditorSceneManager.sceneSaving += SceneSaving;
}
private static void SceneSaving(Scene scene, string path)
{
GameObject.Find("TEST").GetComponent<Image>().color = Color.red;
}
}
Add a UI Image component to the scene, name its game object “TEST” and make it a prefab.
create the script above, hit save on your scene, observe how the Image color turns red, the post processor is working.
Reopen the scene and observe, that the changes were not saved. You can also see that there is no indicator on the prefab that normally appear when you add overrides manually.
If you try the same without making the object a prefab it also works as expected.