예제 #1
0
 void InvokeBtn(object seder, IntPassEventArgs e)
 {
     if (!plat.GetPlatContent().GetButton(e.id).isFreeze)
     {
         BtnFunction(e.id);
     }
 }
예제 #2
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();
        }
    }