Search Issue Tracker
By Design
Votes
33
Found in
2020.3.39f1
2021.3.8f1
2022.1.14f1
2022.2.0b6
2023.1.0a8
2023.2.0a1
Issue ID
UUM-12454
Regression
No
Serialized field values are lost when switching between branches using Git
Reproduction steps:
# Open the attached project
# Open the “/Assets/Scenes/SampleScene.unity” Scene
# Select the “MyData” GameObject in the Hierarchy window
# Checkout the “develop” branch in Git
# Observe the Serialized “My Behavior” Script fields in the Inspector window
# Checkout the “remove-mybehavior-field” branch in Git
# Observe the Serialized “My Behavior” Script fields in the Inspector window
# Checkout the “develop” branch in Git
# Observe the Serialized “My Behavior” Script fields in the Inspector window
Expected result: Serialized field contains MyData Asset
Actual result: Serialized field is empty
Reproducible with: 2020.3.39f1, 2021.3.8f1, 2022.1.14f1, 2022.2.0b6, 2023.1.0a8
Reproducible on: Windows 10 (21H2)
Notes:
* Reloading the Scene fixes the issue when the GameObject in the Scene is affected, however, if a ScriptableObject is affected, only “Reimport All” or Editor restart fixes the issue
* The Editor has to be open when switching to another branch and the Editor has to recompile once a new branch has been loaded
-
RickshawDerpyDerp
Jan 17, 2024 00:12
It's 2024 and I just "Add"ed a remote project on my laptop using Unity's version control system in Unity Hub. It's completely fresh, yet once all the files load, every serialized field is empty. Nothing has been commented at any time and the project is intact on my desktop workstation at home. I opened the scene fresh because it isn't open when I open the project (as it has never been opened on my laptop before). It should load with thr fields filled in as they were in the editor, but it does not. Reloading isn't going to fix the problem. I have to go back home and manually set default values in those scripts. Moreover, unless I change those default values, I can't count on my changes being saved across workstations.
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Standalone Player crashes with "TDerived GetOrLoad<TDerived>() where TDerived : T" when IL2CPP Code generation is set to "Faster (smaller) Builds"
- IndexOutOfRangeException and InvalidOperationException when logging XML string
- Script missing in "Assets/Settings/Mobile_Renderer/GlobalVolumeFeature" of "com.unity.template.urp-blank" template
- “Font Asset Creator - Error Code [Invalid_File_Structure]…“ error is logged when generating Font Assets from fonts with meta files from previous Editor versions
- Input.mousePosition returns (NaN, NaN, 0.00) when Scene view is opened
Resolution Note:
Hi, we do recognize this can be a troublesome issue, but it is not a new issues, it has been there even since Mono and Domain reloads were introduced. A simple way to reproduce it is the following:
1. You have a script with public field and it has some value (stored in the scene file).
2. You comment out this field. After domain reload it is gone (value is still in the scene file of course).
3. You un-comment it back. After the domain reload the field has default value (the actual value is still in the scene file and "come back" after scene reload).
The reason this has not been fixed is because it would be a massive iteration slow down. Basically we would have to reload EVERYTHING when you make changes to a script and that is simply not acceptable in the most common case.
We know this is not great, but the recommendation is to close the editor when switching branches in version control or at least but have any scenes open, though that will not handle the ScriptableObject asset case.