protected internal override void OnInit(object userData) { base.OnInit(userData); basketBallBtn.AddUnSelected(OnBtnUnSelected).AddSelected(OnBtnSelected); GameEntry.UIEvent.AddOnClickHandler(basketBallBtn, (obj) => { GameEntry.Event.Fire(this, EnterGameEventArgs.Create(SceneId.BasketBall)); }); }
protected internal override void OnInit(object userData) { base.OnInit(userData); //Log.Debug("loading init"); GameEntry.UIEvent.AddOnClickHandler(searchBtn, (obj) => { statusText.text = "搜索中..."; UdpRecv.Instance.Init(new IPEndPoint(IPAddress.Any, 7777)); UdpRecv.Instance.ReceiveEventHandler = (bytes, endPoint) => { string info = System.Text.Encoding.UTF8.GetString(bytes); Log.Debug("{0} {1} ----- {2}", endPoint.Address.ToString(), endPoint, info); string targetIp = "172.16.4.112"; if (targetInput.text.Length > 0) { targetIp = targetInput.text; } if (endPoint.Address.ToString().Equals(targetIp)) { string[] array = info.Split('-'); string ip = array[0]; string port = array[1]; //string type = array[2] //盒子型号 targetEndPoint = new IPEndPoint(IPAddress.Parse(ip), int.Parse(port)); Log.Debug("search finish"); Loom.QueueOnMainThread(() => { statusText.text = "搜索成功"; }); UdpRecv.Instance.Dispose(); } }; }); GameEntry.UIEvent.AddOnClickHandler(connectBtn, (obj) => { statusText.text = ""; UDPManager.Instance.Connect(targetEndPoint); }); GameEntry.UIEvent.AddOnClickHandler(basketBallBtn, (obj) => { GameEntry.Event.Fire(this, EnterGameEventArgs.Create(SceneId.BowlingPhone)); }); }