- Home /
 
               Question by 
               prabha1994 · Oct 05, 2015 at 10:54 AM · 
                inspectortexture2dguitextureunassiunassignedreferenceexception  
              
 
              Unassigned Reference Exception. How to create and add a texture 2D in the inspector?
I am trying to create a timer to the game. When i execute this code, it shows an Unassigned Reference Exception. I tried creating an image file and adding it to the timerbar in the inspector field, but was not able to do it. Please help me in creating an texture 2d (a monocolour rectangle would be enuf) file and adding it to the inspector.
void Start() { runTimer = true; }
  void Update() {
      if(runTimer  == true) {
             timer_cur -= Time.deltaTime;
             if(timer_cur  >= 0) {
                   timer_cur = timer_max
             }
      }
  }
 
  void OnGUI() {
        if(runTimer == true) {
             int pos_x = Screen.width / 2 - timerBar.width / 2;
             int pos_y = 100;
             int width = Mathf.RoundToInt(timer_cur / timer_max * timerBar.width);
             GUI.DrawTexture(new Rect(pos_x, pos_y, width , timerBar.height), timerBar);
        }
  }
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                