GUIStyle <-> GUISkin, why quotation marks does such difference

Hi there. I have a huge ( +100 elements ) array, and every part of it have different GUIStyle implemented at the beginning. I tried to make a loop which displays all of these elements as a toggles on screen with a loop. Everything works good, except for the one thing : i got problems with >Unable to find style ‘XH’ in skin ‘GameSkin’ Repaint< Error. My loop looks like that :

	for (var i = 1; i <= 50; i=i+4){
		tx[i] = GUI.Toggle(Rect(0, (b-1)*68, 60, 60), tx[i], "",Namelist.names[i]);
		tx[i+1] = GUI.Toggle(Rect(68,(b-1)*68, 60, 60), tx[i+1], "",Namelist.names[i+1]);
		tx[i+2] = GUI.Toggle(Rect(136,(b-1)*68, 60, 60), tx[i+2], "",Namelist.names[i+2]);
		tx[i+3] = GUI.Toggle(Rect(204,(b-1)*68, 60, 60), tx[i+3], "",Namelist.names[i+3]);
		b++;
	}

In other script named Namelist, i got this array ( names[125] ), which have implemented strings ( names[1] =“bobby” ). This array is static var. Also, in script, where this loop is located, i have implemented styles this way :

	var bobby : GUIStyle;

The problem is, i got this error. The funny part is that if i manually write guistyle name in this loop, it works !

		tx[i] = GUI.Toggle(Rect(0, (b-1)*68, 60, 60), tx[i], "",bobby);

Just like this. But this array is huge, so writing manually +100 positions is bad idea i guess… I dont know what to do, but there is alittle clue : when I write manually guistyle name, but with quotation marks, the program things its GUISkin, and automatically it throws same error, like with my loop->array system ! I mean like this :

	tx[i] = GUI.Toggle(Rect(0, (b-1)*68, 60, 60), tx[i], "","bobby");

So is there any way to work this one out ? :slight_smile:

guistyles should be provided as a string
So: Toggle(someRect, someBoolean, someString, someGUIStyleStringName)

Do you have a guistyle set up for every name?
Is there definatly a style called “XH”?

I have exacly same arguments for toggle ! I have guistyle set up for every name, and for sure there are all of needed styles ( he cant find ANY of them ). Then problem is, that compiler thinks this is guiSKIN named bobby ( like writing “bobby” in >someGUIStyleStringName< ) instead of guiSTYLE ( like writing bobby without >" "< in >someGUIStyleStringName< ). I have no idea how to make the compiler see the difference :frowning:

no it’s not looking for a guiskin called bobby, its looking for a style called bobby in the current skin

try casting
Namelist.names
which is a string, to a guistyle

Problem solved :slight_smile: I had to implement it in the same scriptfile :> Now it works

static var names = Array(125);
var bobby : GUIStyle;
names[1]=bobby;

That is not a fix, you could just store the GUIStyles in the array or cast them to a GUIStyle. Creating a variable for each one kinda defeats the object of the array.