Hi, my score int is always 0 and doesn’t increment. I can’t seem to affect the “score” value unless I declare a value in the awake function. It should increment “score” every time I go back to the scene that this game object is active in (just for testing to make more complex later).
Please advise.
#pragma strict
var control : GameControl;
var score : int;
var ScoreText : UnityEngine.UI.Text;
function Awake () {
Debug.Log("GameControl runs");
Debug.Log(score);
ScoreText.text = "Score: " + score.ToString();
if (control == null)
{
DontDestroyOnLoad(gameObject);
control = this;
Debug.Log(control);
score = score + 1;
} else if (control != this)
{
Destroy(gameObject);
Debug.Log("Destroy?");
}
}
function Update () {
score = score + 1;
}