Simon Gomes
Simon Gomes

Reputation: 383

Unity-Monodevelop Variable Synching issue

I have added a C# Script to the Main Camera. I defined a variable MyNumber like below -

public int MyNumber = 9;

My problem is when I change the value of the variable; inside the Unity Editor it remains the same. For example if I change the value from 9 to 19 in the C# script file using Monodevelop, the Unity Editor continues to show My Number = 9 instead of 19; unless I reset the script file.

Please check the screenshot: Variable not syncing properly

Upvotes: 2

Views: 74

Answers (1)

Ifrit
Ifrit

Reputation: 6821

This is normal behavior. There's no way for the Unity Editor to know if the old value of 9 was purposely changed in the editor from the default found within your C# script. So it plays it safe and assumes it was modified.

It's important to remember that the script initialized value represents a default value. It does not always guarantee the starting value. Case in point, it's updated in the editor.

Upvotes: 5

Related Questions