Exemplo n.º 1
0
    public void UpdateServerList()
    {
        foreach (ServerRowGUI row in rows)
        {
            if (row != null)
            {
                Destroy(row.gameObject);
            }
        }

        rows.Clear();

        int i = 0;

        foreach (RemoteServer server in ClientUDP.singleton.availableGameServers)
        {
            ServerRowGUI row = Instantiate(prefabServerRowGUI, transform);

            RectTransform rt = (RectTransform)row.transform;
            rt.localScale = Vector3.one;
            rt.sizeDelta  = new Vector2(500, 50);
            rt.anchorMax  = rt.anchorMin = new Vector2(0.5f, 0.5f);
            rt.pivot      = new Vector2(0.5f, 0.5f);

            rt.anchoredPosition = new Vector2(0, -i * 70);

            row.Init(server, this);
            row.transform.SetParent(connectionScreen.transform);
            rows.Add(row);
            i++;
        }
    }
Exemplo n.º 2
0
    public void UpdateServerList()
    {
        //remove all old rows
        foreach (ServerRowGUI row in rows)
        {
            if (row != null)
            {
                Destroy(row.gameObject);
            }
        }
        //clear list
        rows.Clear();

        //populate new rows:
        int i = 0;

        foreach (RemoteServer server in ClientUDP.singleton.availableGameServers)
        {
            ServerRowGUI  row = Instantiate(prefabServerRowGUI, transform);
            RectTransform rt  = (RectTransform)row.transform;
            rt.localScale = Vector3.one;
            rt.sizeDelta  = new Vector2(500, 50);
            rt.anchorMax  = rt.anchorMin = new Vector2(.5f, .5f);
            rt.pivot      = new Vector2(0.5f, 0.5f);

            rt.anchoredPosition = new Vector2(0, i * -70);

            row.Init(server);
            rows.Add(row);
            i++;
        }
    }