PostProcessSceneAttribute : how to save scene modifications ?

Hello guys,

I’m using PostProcessSceneAttribute to call a method that retrieve in the current scene a script and call a method on that script. The called method will made modifications to the scene (in order to make the scene liter) which can be restored using another method at runtime. After the method is called I used :

EditorSceneManager.MarkAllScenesDirty ();

            EditorSceneManager.SaveOpenScenes ();

But regarding the Build reports I can say for sure that the method modifications have not been saved. I know that the method works because I tried it before from the editor.

So my question is, is it possible to modify the “builded” scene and modified it ?

Thanks

The UnityEditor namespace is only available in-editor, and not in builds. Also, any scripts in a folder called “Editor” will not be compiled as part of the build.

Hi,

Actually you have to use the Editor namespace to use PostProcessSceneAttribute and I can confirm that my method is correctly called and do what it has to do because I put some Debug inside. The only problem is that modifications made to the scene are not saved.

Ho - I have to apologize here - actually modifications was correctly saved - I did not pay enough attention !

But now it make me ask another question. I’d like scene modifications to be applied into the build scene and not the original scene. But according to my last tests modifications are applied and save to the original scenes.

Thanks

PostProcessScene stuff is applied to the “build” scene automatically. It’s only if you explicitly set things dirty (as you do) that they’re also applied to the original scene.

PostProcessScene happens both when you build and when you enter the scene in play mode, so you’ll see the same thing happen in both instances - unless you check Application.IsPlaying or BuildPipeline.IsBuildingPlayer.

Hum, I want to trust you but it’s not what I have experienced so far. If I do not set the scene as dirty the build scenes seem to not be modified. I will keep making tests because it’s new for me and it’s possible thatI made mistakes.