I have a custom build script that triggers via a menu item for specific configurations of the project. I utilize EditorSceneManager and FindObjectOfType to Open the main scene, find the startup controller and change a public property on its instance. Then I call SaveOpenScenes, BuildPlayer then I restore the previous value to the property. If I do not call BuildPlayer or restore I can see the value changed correctly in the Scene and Inspector of the GameObject, the scene is not marked as dirty because I called Save. However, if BuildPlayer is called passing in the same path of the Scene the resulting build will not have the changes to the property that I made via code before calling BuildPlayer. How can I make sure my changes stick around for the build?
Was able to get the changes to stick by adding EditorUtility.CopySerialized(component_with_changed_properties, component_with_changed_properties); after changing the values before calling SaveOpenScenes