- Home /
Creating an array of gui styles and using them
I have an array of styles:
public GUIStyle[] styles;
When using one of these styles on a label nothing shows up
GUILayout.Label("Foo Bar", styles[0]);
It works as it should when the styles aren't in an array such as
GUILayout.Label("Foo Bar", style);
Have I done something wrong?
Comment
Answer by yyamiyyugi · Jul 12, 2014 at 06:06 AM
You need to define the scope of the array, you can do this by either changing
public GUIStyle[] styles;
To
public GUIStyle[] styles = new GUIStyle[insert size of array];
or you can add
styles = new GUIStyle[insert size of array];
to your start function