Unity Issue Tracker - variable's value is overwritten when the variable previously was Public and set up via Inspector
Closed
UUM-42808
variable's value is overwritten when the variable previously was Public and set up via Inspector
Unity: Inspector Framework
HideInInspector
As Designed
2023.2.X
2023.1.X
2022.3.X
2021.3.X
HideInInspector does not change the value of the serialized field, which is saved with the scene. If you use [System.NonSerialized] instead, it will not show in the inspector and behave in the way you expect.
How to reproduce:
1. Open the attached project “HideBug”
2. Open the “SampleScene” scene
3. In the Hierarchy select the “GameObject” GameObject
4. In the Inspector under the “Test” Script check the “Wow” variable
5. Open the “test” Script and uncomment the [HideInInspector] line
6. Enter the Play Mode
7. Observe the Console
Expected result: “False” is logged into the Console because this value is set in the Script
Actual result: “True” is logged into the Console because this value was previously set in the Inspector