/// <summary> /// 创建新的socket实例 /// </summary> public void NewSocket() { string addr = addressInput.text; if (webSocketEntityDic.ContainsKey(addr)) { MessageBox("Duplicate address " + addr); return; } WebSocketEntry entry = new WebSocketEntry(addr); webSocketEntityDic.Add(addr, entry); Button entryItem = GameObject.Instantiate(entryTemplate); entryItem.GetComponentInChildren <Text>().text = addr; entryItem.gameObject.SetActive(true); entryItem.transform.SetParent(entryRoot); entryItem.transform.localScale = Vector3.one; entryItem.transform.localRotation = Quaternion.identity; entryItem.onClick.AddListener(() => { OnEntryItemClick(entry); }); if (webSocketEntry == null) { webSocketEntry = entry; } }
private void OnEntryItemClick(WebSocketEntry entry) { m_selectedEntry = entry; }
/// <summary> /// 确定所选择的websocket实例 /// </summary> /// <param name="entry"></param> private void OnEntryItemClick(WebSocketEntry entry) { webSocketEntry = entry; }
private void OnEntryItemClick(Button sender, WebSocketEntry entry) { ChangeSelected(sender); m_selectedEntry = entry; }