Question | GUIStyle [].name not working for me

Am I missing something here?

// var GUIStyle
var guistyTes : GUIStyle;
var guistyBut : GUIStyle[];
  guistyBut = new GUIStyle[41];


// Works
guistyTes.name = "Test1";


// Does not work
// NullReferenceException: 
// Object reference not set to an instance of an object
guistyBut[1].name = "Test2";

Tried labeling as PRIVATE but still fails.

Thanks.

Remove the following:

guistyBut = new GUIStyle[41];

This creates an EMPTY array of type GUIStyle, and wipes out the array created in the inspector (which is what I assume you’re trying to do).

Dnk, Dnk, Dnk (head against table)…

Thank you for your response.

I tested your suggestion and it is correct.

Thanks.