Example #1
0
    /*content在執行Inialize時就必需加入上下左右BtnContent
     * 因此content必需在intialize之前便初始化完畢
     * 否則在加入上下左右時,其它BaseButton的BtnContent還未初始化
     */

    public void Initialize()
    {
        content.onChangeStae += OnBtnStateChange;
        content.SetBaseButton(this);
        content.ID = id;

        if (up != null)
        {
            content.up = up.GetBtnContent();
        }
        if (left != null)
        {
            content.left = left.GetBtnContent();
        }
        if (right != null)
        {
            content.right = right.GetBtnContent();
        }
        if (down != null)
        {
            content.down = down.GetBtnContent();
        }

        if (plat == null)
        {
            var plat = transform.parent.GetComponent <BasePlat>();
            if (plat != null)
            {
                this.plat = plat;
                plat.GetPlatContent().AddButton(this.content);
            }
            else
            {
                Debug.LogError("button miss plat in " + transform.parent.gameObject.name + "/" + gameObject.name);
            }
        }

        var components = GetComponents <IUIComponent>();

        foreach (var component in components)
        {
            component.Initialize();
        }
    }
Example #2
0
 public void Initialize()
 {
     plat            = GetComponent <BasePlat>();
     plat.invokeBtn += InvokeBtn;
 }
Example #3
0
 public PlatContent(int id, BasePlat basePlat, IPlatAnima platAnima)
 {
     this.id        = id;
     this.platAnima = platAnima;
     this._basePlat = basePlat;
 }