- Home /
 
 
               Question by 
               Swagonomics101 · Jun 12, 2014 at 02:33 AM · 
                javascriptguivariablelabelguilabel  
              
 
              Need help with GUI label not displaying variable
So I have a GUI label that I want to simply display the value of boxCount, however even when boxCount increments in the inspector (when I collect little boxes), The label stays at 0. Any help would be greatly appreciated!
 //javascript
 
 var boxCount : int;
 
 function OnTriggerEnter (other : Collider) 
 {
     other.gameObject.SetActive(false);
     boxCount = boxCount + 1;
 }
 
 function OnGUI()
 {
 
    GUI.Label (Rect (100,100,50,50), boxCount.ToString(), "box");
 }
 
              
               Comment
              
 
               
              Answer by Swagonomics101 · Jun 12, 2014 at 05:41 AM
ok nevermind all I had to do was put var boxCount : int = 0; and it worked :)
Your answer