Esempio n. 1
0
    // 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;
        }
    }
Esempio n. 2
0
    public BtnContent GetButton(int id)
    {
        InitialBtnList();
        BtnContent target = btnList.Find((x) => x.ID == id);

        return(target);
    }
Esempio n. 3
0
    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);
        }
    }
Esempio n. 4
0
    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);
        }
    }