Hi, I’ve made a script that sets some transforms references to some gameObjects which i call via menuItem which finds every Point and calls a method that modifies the following values:
The information that I modify is a reference to another object component (Point)
My problem here is that whenever I enter playmode or leave the scene the changes are reset. Since these attributes are not (int,float,…) i don’t know how a serialized field would work here.
Any help would be appreciated
What you need is this function:
Unity does not save the changes you made via script unless explicitly told to.
1 Like
@fffMalzbier
Hi I’ve tried doing that like as following:

But the changes still reset after entering play mode (with or without Save scene also)
I think you need to reference the component that was changed in this case its the Script that is including the left variable.
Yup that was the problem, rookie mistake
Thanks!
1 Like
Thank you, kind sir. In Editor script:
- Make your changes to prefab instances
- Call PrefabUtility.RecordPrefabInstancePropertyModifications(referenceToComponent);
- Save the scene (in the script or manually)
Now the edits made in the Editor script are persisted in the scene.
1 Like