Changed array type, different functions?

Hi Forum!

EDIT: I have changed approach to how I create arrays, for my server, and apparently this given me severe problems. I now use the layout of the template chatroom by Unity, with this approach:

class Server_Clientlist_Entry
{
	var text = "";	
	var Style = 1;
}

function Server_Clientlist_Add (str : String, Style : int)
{
	var entry = new Server_Clientlist_Entry();
	entry.text = str;
	Debug.Log(entry);
	if (Style == 1) entry.Style = 1;
	if (Style == 2) entry.Style = 2;
	if (Style == 3) entry.Style = 3;
	if (Style == 4) entry.Style = 4;
	if (Style == 5) entry.Style = 5;	
		
	Server_Clientlist_Entries.Add(entry);
	Server_Clientlist_ScrollPosition.y = 1000000;	
}

This gives me a problem. For some reason, when I try to add lines with this, it prints them right onto the screen, but it stores the name of the class “Server_Clientlist_Entry” in the array, and not the actual string, so I can’t e.g. print or search compare to any index, since all index values are apparently “Server_Clientlist_Entry” … Maybe this is since it uses a class, but how do I avoid this? I want to be able to loop through the index, and check if an entry with the same name already exist. This is an edited thread as I learned more from debugging.

Thanks in advance for your time,
Jeanette

First like Mike said you should use a List instead of an Array. The Array class does the same thing but with untyped content. A generic List is strong typed and therefore is faster and type safe.

I guess your actual problem is the place where you access / display your items. I’m pretty sure you have something like that:

    GUI.Label(..., Server_Clientlist_Entries[some index]);

But you have to access the string like this:

    GUI.Label(..., Server_Clientlist_Entries[some index].text);

You just use the class reference like a string so it returns the class name. You actually want the string that is stored in the text variable of that class.