private void UpdateListElements()
        {
            for (int i = 0; i < listServerListEntries.Count; i++)
            {
                if (i >= ListElementContainer.transform.childCount || ListElementContainer.transform.GetChild(i) == null)
                {
                    continue;
                }
                ListEntryController entryController = ListElementContainer.transform.GetChild(i).GetComponent <ListEntryController>();

                string modifiedAddress = string.Empty;
                if (listServerListEntries[i].ip.StartsWith("::ffff:"))
                {
                    modifiedAddress = listServerListEntries[i].ip.Replace("::ffff:", string.Empty);
                }
                else
                {
                    modifiedAddress = listServerListEntries[i].ip;
                }

                int port = listServerListEntries[i].port;

                string formatStatus = string.Empty;
                if (listServerListEntries[i].extras.Equals("Open"))
                {
                    formatStatus = "<color=green>Open</color>";
                }
                else
                {
                    formatStatus = "<color=yellow>In-Game</color>";
                }

                entryController.titleText.text   = "World " + i;
                entryController.statusText.text  = formatStatus;
                entryController.playersText.text = $"{listServerListEntries[i].players} {(listServerListEntries[i].capacity > 0 ? $"/ {listServerListEntries[i].capacity}" : string.Empty)}";
                // It is up to you to figure out how to do the latency text.
                entryController.latencyText.text = "-";

                entryController.joinButton.onClick.RemoveAllListeners();
                entryController.joinButton.onClick.AddListener(() =>
                {
                    // Debug: Prints CLICKY to see if the button actually was clicked or Unity UI was being dumb
                    // print("CLICKY");
                    NetworkManager.singleton.networkAddress = modifiedAddress;
                    //NetworkManager.singleton.GetComponent<TelepathyTransport>().port = (ushort)port;
                    NetworkManager.singleton.GetComponent <Mirror.Websocket.WebsocketTransport>().port = port;
                    NetworkManager.singleton.StartClient();
                });
            }

            // Done here.
        }
Пример #2
0
        private void UpdateListElements()
        {
            for (int i = 0; i < listServerListEntries.Count; i++)
            {
                if (i >= ListElementContainer.transform.childCount || ListElementContainer.transform.GetChild(i) == null)
                {
                    continue;
                }
                ListEntryController entryController = ListElementContainer.transform.GetChild(i).GetComponent <ListEntryController>();

                string modifiedAddress = string.Empty;
                if (listServerListEntries[i].ip.StartsWith("::ffff:"))
                {
                    modifiedAddress = listServerListEntries[i].ip.Replace("::ffff:", string.Empty);
                }
                else
                {
                    modifiedAddress = listServerListEntries[i].ip;
                }

                entryController.titleText.text   = listServerListEntries[i].name;
                entryController.addressText.text = modifiedAddress;
                entryController.playersText.text = $"{listServerListEntries[i].players} {(listServerListEntries[i].capacity > 0 ? $"/ {listServerListEntries[i].capacity}" : string.Empty)}";
                // It is up to you to figure out how to do the latency text.
                entryController.latencyText.text = "-";

                entryController.joinButton.onClick.RemoveAllListeners();
                entryController.joinButton.onClick.AddListener(() =>
                {
                    // Debug: Prints CLICKY to see if the button actually was clicked or Unity UI was being dumb
                    // print("CLICKY");
                    NetworkManager.singleton.networkAddress = modifiedAddress;
                    NetworkManager.singleton.StartClient();
                });
            }

            // Done here.
        }