Input nick with TextField.

Hello,


void OnServerInitialized()
	{
		//Wybierz nick
		newNick = GUI.TextField(new Rect(10, 10, 200, 20), newNick, 25);
		//Struktura nowego gracza
		Gracze.Add ( new Gracz (networkView.owner.ToString(), newNick ) );
		Gracze[0].Wypisz();
		//Spawning
		SpawnPlayer();
		//Start timiera, powinien być dopiero jak są ze dwie osoby
		Mechanika.leci = true;
	}

Obviously I cant use GUI. outside of OnGUI function. What is the easiest way to make my code working? I want my program to ask a player for his nick OnServerInitialized() || OnConnectedToServer() and then use this nick to create new list object.

As a quick solution I would suggest setting a bool to true in the OnServerInitialized() and polling it in the OnGUI().

Something like this:

bool serverInitialized = false;

void OnServerInitialized()
{
   serverInitialized = true;
   // ...
}

void OnGUI()
{
   if(serverInitialized)
   {
      // New GUI stuff
   }
}