public static GameObject create(string text, OnClickButton onClickButton) { GameObject prefab = Resources.Load("Prefabs/UI/Panel/HasInRoomPanel") as GameObject; GameObject obj = GameObject.Instantiate(prefab, GameObject.Find("Canvas_Middle").transform); obj.GetComponent <HasInRoomPanelScript>().m_content.text = text; obj.GetComponent <HasInRoomPanelScript>().m_OnClickButton = onClickButton; return(obj); }
public void ShowActionWnd(OnClickButton cb, Dictionary <int, string> buttonNames) { ClickButton = cb; foreach (KeyValuePair <int, string> child in buttonNames) { GameObject item = GameObject.Instantiate(button.gameObject); item.transform.parent = this.transform; item.transform.Find("Text").GetComponent <Text>().text = child.Value; item.name = "Button" + child.Key; item.SetActive(true); item.GetComponent <Button>().onClick.AddListener(delegate() { ClickButton(item.name[item.name.Length - 1] - '0'); }); } transform.GetComponent <RectTransform>().sizeDelta = new Vector2(95, buttonNames.Count * 42); }
public void setOnClickButton(OnClickButton onClickButton) { m_OnClickButton = onClickButton; }
public void ClickedButton() { OnClickButton?.Invoke(); }