//刷新界面 public override void RefreshUI() { GameObject hintItem = m_type == 0 ? hintItem1 : hintItem2; Transform parent = m_type == 0 ? parent1 : parent2; if (hintItem != null) { parent.gameObject.SetActive(true); GameObject go = GameObject.Instantiate(hintItem, parent); go.SetActive(true); IggText txt = go.GetComponentInChildren <IggText>(); if (txt != null) { List <string> l = new List <string>(); l.Add(m_msg); txt.SetString(l); } m_List.Add(go); } // 只留3个 int count = m_List.Count; if (count > 3) { for (int i = 0; i < count - 3; i++) { GameObject g = m_List[0]; if (g != null) { GameObject.Destroy(g); } m_List.RemoveAt(0); } } }
private void AddOption(string strOption, uint DialogID, bool first) { if (OptionPrefab != null) { OptionPrefab.SetActive(false); GameObject go = GameObject.Instantiate(OptionPrefab, tOptionParent); go.SetActive(true); Button btn = go.GetComponent <Button>(); btn.onClick.AddListener(() => { StartCoroutine(DoOption(go.GetComponent <Animator>(), DialogID)); }); List <string> l = new List <string>(); l.Add(strOption); IggText txt = go.transform.Find("Text_text_1").GetComponent <IggText>(); if (txt != null) { txt.SetString(l); } IggText txt1 = go.transform.Find("Text_text_2").GetComponent <IggText>(); if (txt1 != null) { txt1.SetString(l); } m_List.Add(go); } }