// Use this for initialization public void Initialize() { try { content = GetComponent <BaseButton>().GetBtnContent(); if (content == null) { throw new Exception("找不到BaseButton元件 @" + transform.GetPath()); } content.onChangeStae += OnBtnStateChange; if (btnImage == null) { btnImage = GetComponent <Image>(); } if (btnImage == null) { throw new Exception("找不到可更改之Image元件 @" + transform.GetPath()); } OnBtnStateChange(this, new EventArgs()); }catch (Exception) { throw; } }
public BtnContent GetButton(int id) { InitialBtnList(); BtnContent target = btnList.Find((x) => x.ID == id); return(target); }
public bool RemoveButton(int id) { InitialBtnList(); BtnContent target = btnList.Find((x) => x.ID == id); if (target != null) { btnList.Remove(target); return(true); } else { return(false); } }
public bool AddButton(BtnContent btn) { InitialBtnList(); BtnContent target = btnList.Find((x) => x.ID == btn.ID); if (target != null) { Debug.LogError(string.Format("按鈕ID重覆 /n{0}/n{1}", btn.baseButton.transform.GetPath(), target.baseButton.transform.GetPath())); return(false); } else { btnList.Add(btn); return(true); } }