Beispiel #1
0
    public void OpenUIWindow(UIWindowType windowType)
    {
        if (m_Dic_UIWindow.ContainsKey(windowType))
        {
            m_Dic_UIWindow[windowType].SetActive(true);
            return;
        }

        GameObject windowUI = null;

        switch (windowType)
        {
        case UIWindowType.Login:
            //windowUI = ResourceMgr.Instance.Load("People", resType : ResourceType.UIWindow);
            break;

        case UIWindowType.Register:
            //windowUI = ResourceMgr.Instance.Load("renwu1", resType: ResourceType.UIWindow);
            break;

        case UIWindowType.HeroWindow:
            windowUI = ResourceMgr.Instance.Load("HeroWindow", resType: ResourceType.UIWindow);

            //windowUI.GetOrAddComponent<UIWindowCtrBase>().windowConType = UIWindowContainerType.LeftTop;
            break;

        case UIWindowType.SelectWindow:
            windowUI = ResourceMgr.Instance.Load("SelectWindow", resType: ResourceType.UIWindow);
            break;

        default:
            break;
        }
        //获取窗口UI控制器
        UIWindowCtrBase windowUICtr = windowUI.GetOrAddComponent <UIWindowCtrBase>();

        windowUICtr.windowType = windowType;
        UIWindowContainerType windowConType = windowUICtr.windowConType;
        Transform             transParentWindowContainer = null;

        switch (windowConType)
        {
        case UIWindowContainerType.Center:
            transParentWindowContainer = UISceneMgr.Instance.currentUISceneCtr.centerContainer;
            break;

        case UIWindowContainerType.LeftBottom:
            transParentWindowContainer = UISceneMgr.Instance.currentUISceneCtr.leftBottomContainer;
            break;

        case UIWindowContainerType.LeftTop:
            transParentWindowContainer = UISceneMgr.Instance.currentUISceneCtr.leftTopContainer;
            break;

        case UIWindowContainerType.RightBottom:
            transParentWindowContainer = UISceneMgr.Instance.currentUISceneCtr.rightBottomContainer;
            break;

        case UIWindowContainerType.RightTop:
            transParentWindowContainer = UISceneMgr.Instance.currentUISceneCtr.rightTopContainer;
            break;

        default:
            break;
        }
        //设置父节点
        windowUI.transform.parent        = transParentWindowContainer;
        windowUI.transform.localPosition = Vector3.zero;
        windowUI.transform.localScale    = Vector3.one;
        windowUI.SetActive(true);
        m_Dic_UIWindow.Add(windowType, windowUI);
        //开始执行动画
        StartActiveUIWindow(windowUI, windowUICtr.windowShowType);
    }
Beispiel #2
0
    /// <summary>
    /// Opens the user interface window.
    /// </summary>
    /// <param name="windowType">Window type.</param>
    public void OpenUIWindow(UIWindowType windowType)
    {
        if (uiWindowDic.ContainsKey(windowType))
        {
            return;
        }
        GameObject uiWindow = null;

        switch (windowType)
        {
        case UIWindowType.Login:
            uiWindow = ResourceManager.Instance.Load("UIWindow_Login", resType: ResourceType.UIWindow);
            break;

        case UIWindowType.Register:
            uiWindow = ResourceManager.Instance.Load("UIWindow_Register", resType: ResourceType.UIWindow);
            break;

        case UIWindowType.Header:
            uiWindow = ResourceManager.Instance.Load("UIWindow_Header", resType: ResourceType.UIWindow);
            break;

        case UIWindowType.Function:
            uiWindow = ResourceManager.Instance.Load("UIWindow_Function", resType: ResourceType.UIWindow);
            break;

        case UIWindowType.Skill:
            uiWindow = ResourceManager.Instance.Load("UIWindow_Skill", resType: ResourceType.UIWindow);
            break;

        case UIWindowType.Progress:
            uiWindow = ResourceManager.Instance.Load("UIWindow_Progress", resType: ResourceType.UIWindow);
            break;

        default:
            break;
        }

        UIWindowControllerBase uiWindowController = uiWindow.GetOrAddComponent <UIWindowControllerBase>();

        uiWindowController.windowType = windowType;

        Transform transParentWindowContainer = null;

        UIWindowContainerType windowContainerType = uiWindowController.windowContainerType;

        switch (windowContainerType)
        {
        case UIWindowContainerType.Center:
            transParentWindowContainer = UISceneManager.Instance.currentUISceneController.centerContainer;
            break;

        case UIWindowContainerType.LeftBottom:
            transParentWindowContainer = UISceneManager.Instance.currentUISceneController.leftBottomContainer;
            break;

        case UIWindowContainerType.LeftTop:
            transParentWindowContainer = UISceneManager.Instance.currentUISceneController.leftTopContainer;
            break;

        case UIWindowContainerType.RightBottom:
            transParentWindowContainer = UISceneManager.Instance.currentUISceneController.rightBottomContainer;
            break;

        case UIWindowContainerType.RightTop:
            transParentWindowContainer = UISceneManager.Instance.currentUISceneController.rightTopContainer;
            break;

        case UIWindowContainerType.RightCenter:
            transParentWindowContainer = UISceneManager.Instance.currentUISceneController.rightCenterContainer;
            break;

        default:
            break;
        }
        uiWindow.transform.parent        = transParentWindowContainer;
        uiWindow.transform.localPosition = Vector3.zero;
        uiWindow.transform.localScale    = Vector3.one;

        uiWindowDic.Add(windowType, uiWindow);

        NGUITools.SetActive(uiWindow, false);
        UIWindowShowAnimationType windowShowAnimationType = uiWindowController.windowShowAnimationType;

        StartActiveUIWindow(uiWindow, windowShowAnimationType: windowShowAnimationType, state: true);
    }