예제 #1
0
    private void AfterPush(EViewType e)
    {
        if (e == EViewType.Normal)
        {
            foreach (ViewBase view in viewStack)
            {
                if (view.gameObject.activeInHierarchy)
                {
                    view.gameObject.SetActive(false);
                }
            }
        }
        else if (e == EViewType.Popup)
        {
            bool meetNormal = false;
            foreach (ViewBase view in viewStack)
            {
                if (meetNormal && view.gameObject.activeInHierarchy)
                {
                    view.gameObject.SetActive(false);
                }
                else if (!view.gameObject.activeInHierarchy)
                {
                    view.gameObject.SetActive(true);
                }

                ViewPropertySt st = ViewPropertyDefinition.GetSt(view.GetType());
                if (st.eViewType == EViewType.Normal)
                {
                    meetNormal = true;
                }
            }
        }
    }
예제 #2
0
    public void Open <T>() where T : ViewBase
    {
        System.Type    t    = typeof(T);
        ViewBase       view = Contains(t);
        ViewPropertySt str  = ViewPropertyDefinition.GetSt(t);

        AfterPush(str.eViewType);


        if (view != null)
        {
            view.gameObject.SetActive(true);
            viewStack.Push(view);
        }
        else
        {
            if (str.IsNull())
            {
                throw new MissingReferenceException("view path is null");
            }
            AssetBundleManager.Instance.Load(str.path, (abi) => {
                GameObject gameObj = GameObject.Instantiate(abi.mainObject) as GameObject;
                Mount2UILayer(str.eViewType, gameObj);
                view = gameObj.AddComponent <T>();
                viewStack.Push(view);
                IfUseMask();
            });
        }
    }
예제 #3
0
    private void IfUseMask()
    {
        if (viewStack.Count <= 0)
        {
            return;
        }
        ViewBase       v   = viewStack.Peek();
        ViewPropertySt str = ViewPropertyDefinition.GetSt(v.GetType());
        EViewType      e   = str.eViewType;

        if (e == EViewType.Popup && !alphaMask.activeInHierarchy)
        {
            alphaMask.SetActive(true);
        }
        else if (e == EViewType.Normal && alphaMask.activeInHierarchy)
        {
            alphaMask.SetActive(false);
        }
    }
예제 #4
0
    public void Close <T>() where T : ViewBase
    {
        System.Type t    = typeof(T);
        ViewBase    view = viewStack.Peek();

        if (view == null)
        {
            throw new System.ArgumentException("not a view exit");
        }
        else if (view.GetType() != t)
        {
            throw new System.ArgumentException("close a view not at top");
        }
        else
        {
            viewStack.Pop();
            GameObject.Destroy(view.gameObject);
            ViewPropertySt str = ViewPropertyDefinition.GetSt(t);
            AfterPop(str.eViewType);
            IfUseMask();
        }
    }