Search Issue Tracker
By Design
By Design in 2023.1.X
Votes
0
Found in
2020.3.39f1
2021.3.9f1
2022.1.16f1
2022.2.0b7
2023.1.0a9
Issue ID
UUM-13496
Regression
No
Variable values in script are not updated after entering Play Mode for first time
How to reproduce:
1. Open attached project
2. In Editor open any Scene (e.g. Assets/Scenes/GameScene)
3. Create any object in Hierarchy (e.g. Cube)
4. Create empty script on new Cube object
5. Open created script
6. In script declare variable with some value:
Example:
{code:java}
private int testVariable = 99;
{code}
7. In Start method print out variable:
Example:
{code:java}
void Start()
{
Debug.Log(testVariable);
}
{code}
8. In Editor enter Play mode and check Console for the printed value
9. Exit Play mode
10. Go back to the script and change value to something else
Example:
{code:java}
private int testVariable = 55;
{code}
11. Wait for recompile to complete
12. In Editor enter Play mode and check Console for the printed value
13. Exit Play mode
14. In Editor Enter play mode again and check Console for the value
Expected results: Variable value printed in console matches the one in the script when entering Play mode for first time.
Actual results: Old variable value is printed when entering Play mode the first time. It is only updated after entering Play mode the second time.
Reproducible on all latest streams 2020.3.39f1, 2021.3.9f1, 2022.1.16f1, 2022.2.0b7, 2023.1.0a9.
Notes:
- Tested on Win11
- Unable to reproduce on fresh/empty project
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
- Look Dev errors are spammed when opening a new HDRP project when Look Dev was added to the layout in the previous project
- URP Scene Templates are not editable when first opened from the New Scene dialog
- Look Dev window flickers when resizing the window after docking it
- UI breaks when Multiplayer Center window section divider is moved too far
- Adaptive Performance documentation link leads to outdated package documentation when the documentation hyperlink is pressed in the Project Settings window
Resolution Note:
This is by design to support hot-reloading https://docs.unity3d.com/Manual/script-Serialization.html. If you want the behaviour you are intending, this could be achieved by adding [System.NonSerialized] attribute to the field.
Resolution Note (2023.1.X):
This is by design to support hot-reloading https://docs.unity3d.com/Manual/script-Serialization.html. If you want the behaviour you are intending, this could be achieved by adding [System.NonSerialized] attribute to the field.