I have this code:
#pragma strict
var balance=0;
function OnMouseDown() {
balance=balance+5;
Destroy (gameObject);
}
function OnGUI () {
GUI.Label (Rect (10, 10, 100, 20), "$"+balance);
}
attached to a money gameObject so that I gain money when it is clicked. When running it however, the GUI works as intended until I click the gameObject. The gameObject disappears as intended but the GUI also disappears. What am I doing wrong and what can I do to fix it?