using System; using System.Net; using UnityEngine; using UnityEngine.Events; public class ServerSelector : MonoBehaviour { public ServerSelectUi Parent { get; set; } public ServerInfo MyServer = new ServerInfo(); public TextRenderer Text; public ButtonRolloverHandler Background; public TextBox ipInput; public void Start() { if (this.ipInput) { this.ipInput.SetText(this.MyServer.Ip, ""); this.ipInput.OnChange.AddListener(new UnityAction(this.OnIpChange)); return; } this.Text.Text = this.MyServer.Name; } private void OnIpChange() { IPAddress ipaddress; if (!IPAddress.TryParse(this.ipInput.text, out ipaddress)) { return; } this.MyServer.Name = "Custom"; this.MyServer.Ip = this.ipInput.text; this.Select(); } public void Select() { this.Background.OutColor = Color.green; this.Background.DoMouseOut(); this.Parent.SelectServer(this); } internal void Unselect() { this.Background.OutColor = Color.white; this.Background.DoMouseOut(); } }