- Home /
 
               Question by 
               DaiMangouDev · Feb 07, 2015 at 09:20 AM · 
                c#guierrorarray  
              
 
              GUISttyle NullReferenceException error. what am I missing ?
Hi I am working with a array of GUIStyles. I am trying to check if the GUIStyle.normal.background at position # is null however I get as error before the check is done
  public static void GetSetStyle()
  {
           GUIStyle[] GUIICOStyle = new GUIStyle[5];
                       for (int i = 0; i < 5; i++)
                       {                         
      if (!GUIICOStyle[i].normal.background) Debug.Log("it is null");
                               
          
                       }
  }
  
"it is null" is not printed instead i get "NullReferenceException: Object reference not set to an instance of an object"
is there something else in the GUIStyle that needs to be set before I try to access the normal.backgrund ?
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by DaiMangouDev · Feb 07, 2015 at 01:24 PM
For others having the same problem.
   public static void GetSetStyle()
   {
            GUIStyle[] GUIICOStyle = new GUIStyle[5];
                        for (int i = 0; i < 5; i++)
                        {  
                        GUIICOStyle = new GUIStyle();
       if (!GUIICOStyle[i].normal.background) Debug.Log("it is null");
                                
           
                        }
   }
Your answer
 
 
             Follow this Question
Related Questions
Array out of range! 1 Answer
Getting ArgumentOutOfRangeException on array c# 1 Answer
NullReferenceException error in an array of objects 0 Answers
Array index out of range error 1 Answer
Distribute terrain in zones 3 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                