So, I haven’t spent a whole lot of time trying to figure this out, but it seems like what I’m doing SHOULD be working.
So, I have this code…
public class Startup : MonoBehaviour {
public GUIStyle[] styles;
public void OnGUI()
{
GUI.Label (new Rect (80, 22, 100, 30), "**", styles["Label"]);
//Cannot implicitly convert type `string' to `int'
GUI.Label (new Rect (80, 22, 100, 30), "**", styles.Label);
//does not contain a definition for `Label' (which makes sense)
GUI.Label (new Rect (80, 22, 100, 30), "**", styles[0]);
// EDIT: throws Array index is out of range.
}
}
I’ve defined a “Label” style to access already, as seen below.
I’d really like to be able to access my Styles with styles[“style_name”]; Am I able to accomplish this?