Master Server--- I am puzzled

Hi there can someone help. For some reason i cannot acces my HostData from the foreach loop? any ideas?

void CallData()

	{
		HostData[] data = MasterServer.PollHostList();
		Debug.Log("We Should See Something Here First " + data + MasterServer.ipAddress);
 		foreach(HostData element in data)

		 {
			Debug.Log("We accessed the foreach loop");
			GUI.Label(new Rect(10,10,200,200),"Ip Address is " + element.gameType);
	 	 }



	}

what error are you getting ?

Im not getting one it just will not get to the line foreach(HostData element in data)i get the “We should see something here first” + data but i dont get to the lines in the foreach

is there data available on the master server ?

Yea i can get the port number, IP, Dedicated server, and more.

and how do you get those ?
a bit more code would help.

All i need is to be able to grab the data and display it in a GUI here is my code

using UnityEngine;

using System.Collections;



public class NetworkingGUI : MonoBehaviour {



	// Use this for initialization

	void Start() {



		

    }

	

	// Update is called once per frame

	void Update () {

		

	}



    public int xPos = 400;// The position of the box in x 

    public int yPos = 300;// the position of the box in y

    public int boxSizeX = 800;

    public int boxSizeY = 600;

    public float hSliderValue = 2;

    public GUIStyle levelButton;

    public Texture2D spacer;

    private string passwordToEdit = "My Password";

    private string stringToEdit =  "Server Name";

    public string maxPlayers = "Max Players";

    public int levelToLoad = 0;

	public bool multiPlayer = false;

	public bool singlePlayer = false;

	public bool menu = true;

	public bool serverList = false;

	

    void OnGUI()

	{

		if(menu == true)

		{

		if(GUI.Button(new Rect(445,300,131,32), "MultiPlayer"))

			{	

				multiPlayer = true;

				singlePlayer = false;

				menu = false;

				serverList = false;

			}

			/*if(GUI.Button(new Rect(250,250,250,100)"Single Player"))

			{

				singlePlayer = true;

				multiPlayer = false;

				serverList = false;

			}*/

		}

		

		

		if(serverList == true)

		{

			GUI.Box(new Rect(Screen.width / 2 - 263 , Screen.height / 2 - 212 ,Screen.width / 2,Screen.height /2), "Server List");

			GUI.Label(new Rect(Screen.width / 2 - 105, Screen.height / 2 - 183, Screen.width / 2 - 329, Screen.height / 2 - 360), "IP Address"); // This si the password field

			if (GUI.Button(new Rect(Screen.width / 2 - 263, Screen.height / 2 + 106, Screen.width / 2, Screen.height / 32), "Refresh"))

	        {

	            MasterServer.ClearHostList();

				MasterServer.RequestHostList("Heroes Of Awesome");

				Debug.Log(MasterServer.port);

				Debug.Log(MasterServer.ipAddress);

				Debug.Log(MasterServer.PollHostList());

				Debug.Log(MasterServer.dedicatedServer);

				Debug.Log(MasterServer.updateRate);

				Debug.Log(MasterServer.PollHostList());

				CallData();

	        }

			if (GUI.Button(new Rect(Screen.width / 2 - 263, Screen.height / 2 + 134, Screen.width / 2, Screen.height / 32), "Back"))

	        {

	            singlePlayer = false;

				multiPlayer = false;

				menu = true;

				serverList = false;

				

	        }

		}

		if(multiPlayer == true)

		{

			singlePlayer = false;

	        GUI.Box(new Rect(Screen.width / 2 - 263 , Screen.height / 2 - 212 ,Screen.width / 2,Screen.height /2), "Network");

	

	        if (GUI.Button(new Rect(Screen.width / 2 - 240, Screen.height / 2 - 44, Screen.width / 8, Screen.height / 8), "Level Select"))

	        {

	            Debug.Log("We Pressed The Button");// When we click the button display a log letting us know 

	        }

	        if (GUI.Button(new Rect(Screen.width / 2 - 240, Screen.height / 2 + 55, Screen.width / 8, Screen.height / 16), spacer, levelButton))

	        {

	            levelToLoad = 1;

	        }

	        if (GUI.Button(new Rect(Screen.width / 2 - 263, Screen.height / 2 + 106, Screen.width / 2, Screen.height / 32), "Create Server"))

	        {

	            NetWorkHelper();

	        }

	        if (GUI.Button(new Rect(Screen.width / 2 - 263, Screen.height / 2 + 134, Screen.width / 2, Screen.height / 32), "Back"))

	        {

	            singlePlayer = false;

				multiPlayer = false;

				menu = true;

				serverList = false;

	        }

			if (GUI.Button(new Rect(Screen.width / 2 + 99, Screen.height / 2 - 60, Screen.width / 13, Screen.height / 31), "Server List"))

	        {

				serverList = true;

	           	singlePlayer = false;

				multiPlayer = false;

				menu = false;

	        }

	        passwordToEdit = GUI.PasswordField(new Rect(Screen.width / 2 + 52 ,Screen.height / 2 - 96,Screen.width / 2 - 329 ,Screen.height / 2 - 360), passwordToEdit, "*"[0], 25);// password input 

	        stringToEdit = GUI.TextField(new Rect(Screen.width / 2 + 52, Screen.height / 2 - 132, Screen.width / 2 - 329, Screen.height / 2 - 360), stringToEdit, 25); // This is to name your server

	        hSliderValue = GUI.HorizontalSlider(new Rect(Screen.width / 2 +50, Screen.height / 2 - 165, Screen.width / 2 - 329, Screen.height / 2 - 360), hSliderValue, 2.0F, 6.0F);

	        GUI.Label(new Rect(Screen.width / 2 - 241, Screen.height / 2 - 96, Screen.width / 2 - 329, Screen.height / 2 - 360), "Server PassWord"); // This si the password field

	        GUI.Label(new Rect(Screen.width / 2 - 241, Screen.height / 2 - 132, Screen.width / 2 - 329, Screen.height / 2 - 360), "Server Name"); // This si the server name input

	        GUI.Label(new Rect(Screen.width / 2 - 241, Screen.height / 2 - 168, Screen.width / 2 - 329, Screen.height / 2 - 360), "Number Of Players"); // This si the server name input

	        GUI.Box(new Rect(Screen.width / 2 + 81, Screen.height / 2 - 194, Screen.width / 2 - 402, Screen.height / 2 - 361),("MaxPlayers" + Mathf.RoundToInt(hSliderValue))); // Display the amount of possible players 

		}

		

		

		

	}

	

	void NetWorkHelper()

	{

		bool useNAT = !Network.HavePublicAddress();

		Network.InitializeServer(Mathf.RoundToInt(hSliderValue), 25000, useNAT);

		MasterServer.RegisterHost("Heroes Of Awesome",stringToEdit, "Name Your Server");

		Application.LoadLevel(levelToLoad);

	}

	

	void CallData()

	{



		



		HostData[] data = MasterServer.PollHostList();

		Debug.Log("We Should See Something Here First " + data + MasterServer.ipAddress);

 		foreach(HostData element in data)

		 {

			Debug.Log("We accessed the foreach loop");

			GUI.Label(new Rect(10,10,200,200),"Ip Address is " + element.gameType);

	 	 }



	}

}

Your ‘calldata’ function is under a button.
It needs to get called constantly, check the docs. it’s in the update function.

No way Will try this now

I love you appels i dont know why i never seen this