Пример #1
0
    //打开一个新的窗口,并选择是否叠在前一个窗口上
    private UIScreen Push(Type screenType, UIDepthConst uIDepthConst, bool hidePrevious = true, params object[] data)
    {
        if (!screenDic.ContainsKey(screenType))
        {
            Debug.LogWarning("You are trying to open a screen not included in the folder");
            return(null);
        }

        Stack <UIScreen> temp = screenOpened[uIDepthConst];

        if (hidePrevious && temp.Count > 0)
        {
            temp.Peek().OnHide();
        }
        UIScreen screenToPush;

        if (screenPool.ContainsKey(screenType))
        {
            screenToPush = screenPool[screenType];
            screenPool.Remove(screenType);
        }
        else
        {
            screenToPush = UnityEngine.Object.Instantiate(screenDic[screenType], depthTrans[uIDepthConst]);
            screenToPush.gameObject.name = screenType.Name;
        }
        screenToPush.OnInit(data);
        temp.Push(screenToPush);
        screenOpened[uIDepthConst] = temp;
        return(screenToPush);
    }
Пример #2
0
    //关闭当前打开的窗口,并打开前一个窗口
    public UIScreen Pop(UIDepthConst uIDepthConst)
    {
        UIScreen screenToPop = screenOpened[uIDepthConst].Pop();

        screenToPop.OnHide();
        AddScreenToPool(screenToPop);
        if (screenOpened[uIDepthConst].Count > 0)
        {
            screenOpened[uIDepthConst].Peek().OnShow();
        }
        return(screenToPop);
    }
Пример #3
0
    //打开一个消息提示
    private UIScreen ShowMessage(Type screenType, UIDepthConst uIDepthConst, params object[] data)
    {
        if (!screenDic.ContainsKey(screenType))
        {
            Debug.LogWarning("You are trying to open a screen not included in the folder");
            return(null);
        }
        if (openingMsgScreen.ContainsKey(screenType))
        {
            Destroy(openingMsgScreen[screenType].gameObject);
            openingMsgScreen.Remove(screenType);
        }

        UIMessage msgScreen = UnityEngine.Object.Instantiate(screenDic[screenType], depthTrans[uIDepthConst]) as UIMessage;

        openingMsgScreen.Add(screenType, msgScreen);
        msgScreen.OnInit(data);
        return(msgScreen);
    }
Пример #4
0
 //重载, 泛型, where用于约束泛型
 //Push用打开某个UI界面
 public T Push <T>(UIDepthConst uIDepthConst, bool hidePrevious = true, params object[] data) where T : UIScreen
 {
     return((T)Push(typeof(T), uIDepthConst, hidePrevious, data));
 }
Пример #5
0
 //重载, 泛型, where用于约束泛型
 //Push用打开某个UI界面
 public T ShowMessage <T>(UIDepthConst uIDepthConst, params object[] data) where T : UIMessage
 {
     return((T)ShowMessage(typeof(T), uIDepthConst, data));
 }