Hi there!
I noticed that if I modify a script while game is playing and then go back to Unity, static variables loose their values.
Here is a simple script that shows this behavior:
using UnityEngine;
using System.Collections;
public class StaticTest : MonoBehaviour {
public static string s;
// Use this for initialization
void Awake () {
s = "A";
Invoke("SetString",1.0f);
}
void SetString(){
StaticTest.s = "B";
print("String set to: " + s);
}
void OnEnable(){
print("ena, string: " + s);
}
void OnDisable(){
print("dis, string: " + s);
}
}
To try it just run it, after a second go to MonoDevelop, edit the script by just adding a space, save it and go back to Unity.
You can see in the console that string “s” looses its value.
Do I’m doing something wrong?
Thank you very much