Ejemplo n.º 1
0
        ServerHostListLineWidget GetDisplayWidget(int hostIdx, ServerHostListLineWidget[] displays)
        {
            ServerHostListLineWidget widget = hostIdx < displays.Length ? displays[hostIdx] : null;

            if (widget == null)
            {
                GameObject gObj = (Instantiate(serverDisplayPrefab.gameObject) as GameObject);
                widget = gObj.GetComponent <ServerHostListLineWidget>();
                //get or make the matching widget
            }
            return(widget);
        }
Ejemplo n.º 2
0
        private IEnumerator RefreshHostList(TheKeepStudios.network.ClientManager client)
        {
            yield return(null);            //ensure we are NOT on the GUI update frame

            client.RefreshHostList();
            ServerHostListLineWidget[] displays = GetComponentsInChildren <ServerHostListLineWidget>();
            HostData[] hosts = this.clientManager.HostList;
            for (int hostIdx = 0; hostIdx < hosts.Length || hostIdx < displays.Length; ++hostIdx)
            {
                HostData host = hostIdx < hosts.Length ? hosts[hostIdx] : null; //get the host data if it exists
                ServerHostListLineWidget widget = GetDisplayWidget(hostIdx, displays);
                widget.transform.SetParent(this.gameObject.transform, false);   //set ourselves as the parent object for the new widget
                widget.Host = host;                                             //update the widget host
            }
        }