Пример #1
0
    /// <summary>
    /// 显示窗口UI
    /// </summary>
    /// <param name="type"></param>
    /// <returns></returns>
    public GameObject ShowWindowUI(WindowUIType type)
    {
        GameObject go = null;

        if (!windowUIDic.ContainsKey(type))
        {
            //枚举名称要与预设名称对应
            go = ResourcesManager.Instance.Load(ResourceType.WindowUI, type.ToString());
            if (go == null)
            {
                return(null);
            }

            windowUIDic.Add(type, go);

            go.transform.parent        = windowUIparent;
            go.transform.localPosition = Vector3.zero;
            go.transform.localScale    = Vector3.one;
            go.transform.eulerAngles   = Vector3.zero;
        }
        else
        {
            go = windowUIDic[type];
        }

        go.SetActive(true);
        return(go);
    }
Пример #2
0
    /// <summary>
    /// 打开窗口
    /// </summary>
    /// <returns>The window.</returns>
    /// <param name="type">窗口类型</param>
    public GameObject OpenWindow(WindowUIType type)
    {
        GameObject obj = null;

        if (!dicWindows.ContainsKey(type))
        {
            // 窗口名字必须与窗口类型保持一致
            string windowName = string.Format("pan{0}", type.ToString());
            obj = ResourcesMgr.Instance.Load(ResourcesMgr.ResourceType.UIWindow, windowName, cache: true);;
            if (obj == null)
            {
                Debug.Log(string.Format("Resources load {0} failed", windowName));
                return(null);
            }

            obj.transform.parent        = UIRootMgr.Instance.CurrentUIScene.ContainerCenter;
            obj.transform.localPosition = Vector3.zero;
            obj.transform.localScale    = Vector3.one;
            NGUITools.SetActive(obj, false);

            UIWindowBase windowBase = obj.GetComponent <UIWindowBase>();
            if (windowBase == null)
            {
                return(null);
            }

            windowBase.currentUIType = type;
            dicWindows.Add(type, windowBase);

            StartShowWindow(windowBase, true);
        }
        else
        {
            obj = dicWindows[type].gameObject;
        }

        // 动态调整最上层的界面的层级
        UILayerMgr.Instance.AdjustLayer(obj);

        return(obj);
    }
Пример #3
0
    /// <summary>
    /// 打开窗口
    /// </summary>
    /// <param name="type">窗口类型</param>
    /// <returns></returns>
    public GameObject OpenWindow(WindowUIType type)
    {
        if (type == WindowUIType.None)
        {
            return(null);
        }

        GameObject obj = null;

        //如果窗口不存在 则
        if (!m_DicWindow.ContainsKey(type))
        {
            // Debug.Log(string.Format("Panel_{0}", type.ToString()));
            //枚举的名称要和预设的名称对应
            obj = ResourceMgr.Instance.Load(ResourceMgr.ResourceType.UIWindow, string.Format("Panel_{0}", type.ToString()), cache: true);
            if (obj == null)
            {
                return(null);
            }
            UIWindowViewBase windowBase = obj.GetComponent <UIWindowViewBase>();
            if (windowBase == null)
            {
                return(null);
            }

            m_DicWindow.Add(type, windowBase);

            windowBase.CurrentUIType = type;
            RectTransform transParent = null;

            switch (windowBase.containerType)
            {
            case WindowUIContainerType.Center:
                transParent = SceneUICtrl.Instance.CurrentUIScene.Container_Center;
                break;
            }

            obj.transform.SetParent(transParent);
            obj.transform.localPosition = Vector3.zero;
            obj.transform.localScale    = Vector3.one;
            obj.gameObject.SetActive(false);
            StartShowWindow(windowBase, true);
        }
        else
        {
            obj = m_DicWindow[type].gameObject;
        }

        return(obj);
    }
Пример #4
0
    /// <summary>
    /// 打开窗口
    /// </summary>
    /// <param name="type">窗口类型</param>
    /// <returns></returns>
    public GameObject OpenWindow(WindowUIType type)
    {
        if (type == WindowUIType.None)
        {
            return(null);
        }

        GameObject obj = null;

        //如果窗口不存在 则
        if (!m_DicWindow.ContainsKey(type))
        {
            //枚举的名称要和预设的名称对应
            obj = ResourcesMgr.Instance.Load(ResourcesMgr.ResourceType.UIWindow, string.Format("pan{0}", type.ToString()), cache: true);
            if (obj == null)
            {
                return(null);
            }
            UIWindowBase windowBase = obj.GetComponent <UIWindowBase>();
            if (windowBase == null)
            {
                return(null);
            }

            m_DicWindow.Add(type, windowBase);

            windowBase.CurrentUIType = type;
            Transform transParent = null;

            switch (windowBase.containerType)
            {
            case WindowUIContainerType.Center:
                transParent = SceneUIMgr.Instance.CurrentUIScene.Container_Center;
                break;
            }

            obj.transform.parent        = transParent;
            obj.transform.localPosition = Vector3.zero;
            obj.transform.localScale    = Vector3.one;
            NGUITools.SetActive(obj, false);

            StartShowWindow(windowBase, true);
        }
        else
        {
            obj = m_DicWindow[type].gameObject;
        }
        //层级管理
        LayerUIMgr.Instance.SetLayer(obj);
        return(obj);
    }
Пример #5
0
    /// <summary>
    /// 窗口UI加载
    /// </summary>
    /// <param name="type">窗口类型</param>
    /// <returns></returns>
    public GameObject OpenWindow(WindowUIType type)
    {
        if (type == WindowUIType.None)
        {
            return(null);
        }

        GameObject go = null;

        UIWindowBase windowBase = null;

        if (!m_WinDic.ContainsKey(type))
        {
            //这里要去预设的前缀要跟WindowUIType的枚举名称一致
            string prefabName = type.ToString() + "Window";

            go = ResourcesMgr.Instance.Load(ResourcesType.UIWindow, prefabName, true);

            if (go == null)
            {
                return(null);
            }

            //获取该窗口的UIWindowBase
            windowBase = go.GetComponent <UIWindowBase>();

            if (windowBase == null)
            {
                return(null);
            }

            windowBase.curWindowType = type;

            m_WinDic.Add(type, windowBase);

            Transform container = null;

            switch (windowBase.containerType)
            {
            //获取该窗口应该挂在场景UI的哪个九宫格挂点上
            case ContainerType.Center:
                container = SceneUIMgr.Instance.currentUIScene.m_ContainerCenter;
                break;
            }

            go.transform.parent        = container;
            go.transform.localPosition = Vector3.zero;
            go.transform.localScale    = Vector3.one;
            NGUITools.SetActive(go, false);
        }
        else
        {
            windowBase = m_WinDic[type];
            go         = windowBase.gameObject;
        }

        StartWindowShow(windowBase, true);

        //设置层级,最新打开的窗口的层级depth会自动增加层级数量(50为基数),以保证它在视图的最前面
        LayerUIMgr.Instance.SetLayer(go);

        return(go);
    }
Пример #6
0
    /// <summary>
    /// 打开窗口
    /// </summary>
    /// <param name="windowUIType">窗口类型</param>

    /// <returns></returns>
    public GameObject OpenWindow(WindowUIType windowUIType, Transform transParent = null)
    {
        if (windowUIType == WindowUIType.None)
        {
            return(null);
        }
        GameObject obj = null;

        UIBase windowBase = null;

        if (!dicWindow.ContainsKey(windowUIType))
        {
            //前提:枚举的名字必须和预制件的名字一致
            obj = ResourcesMgr.Instance.Load(ResourcesType.UIPrefabs, string.Format("{0}", windowUIType.ToString()), true);
            if (obj == null)
            {
                return(null);
            }
            windowBase = obj.GetComponent <UIBase>();
            if (windowBase == null)
            {
                return(null);
            }
            windowBase.curretnUIType = windowUIType;
            dicWindow.Add(windowUIType, windowBase);
            obj.transform.parent        = transParent;
            obj.transform.localPosition = Vector3.one;
            obj.transform.localScale    = Vector3.one;
            NGUITools.SetActive(obj, false);
        }
        else
        {
            obj        = dicWindow[windowUIType].gameObject;
            windowBase = obj.GetComponent <UIBase>();
        }

        StartShowWindow(windowBase, true);

        return(obj);
    }