split as content

Hi there,
I’ve got a problem. I want to split a string and place it in a label of the for loop.
This is the code:

for(int i = index; i < index2; i++) {
			GUILayout.BeginArea(new Rect(20, (height + (12 * i)), 110, 20));
			string[ ] split =  friendidstring.Split(":"[0]);
			GUILayout.Label("online: " + split[-1 + i]);

			GUILayout.EndArea();
}

But I get this error:
GUI Error: You are pushing more GUIClips than you are popping. Make sure they are balanced)

And:
IndexOutOfRangeException: Array index is out of range.
Friends.FriendsWindow (Int32 windowID) (at Assets/Highscore/Script/Friends.cs:93)
UnityEngine.GUI.CallWindowDelegate (UnityEngine.WindowFunction func, Int32 id, UnityEngine.GUISkin _skin, Int32 forceRect, Single width, Single height, UnityEngine.GUIStyle style) (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/GUI.cs:1395)

Can someone help me with how to split that string and how i can place this into my for loop with the label.
And that the first loop has split[0] and the second split[1].

with friendly greetz

Dennisjo1

You should do string operations like that outside OnGUI. Like Update, OnGUI runs every frame, and you don’t want to continuously do string splitting every frame. Anyway, the error says you’re trying to refer to an item in the array that does not exist. If you fix that, the other error should stop.

–Eric

That is the problem. I can’t solve this solution.
split needs to load all the splits.
And I don’t want 100 of string variables where i can put the names of all splitted names.

with friendly greets

Dennisjo1

Founded solution.
I’ve worked whit arrays.

Thanks for the help.