Ejemplo n.º 1
0
    public WindowCfg GetWindowCfgDic(int id)
    {
        WindowCfg trc = null;

        if (WindowCfgDic.TryGetValue(id, out trc))
        {
            return(trc);
        }
        return(null);
    }
Ejemplo n.º 2
0
        /// <summary>
        /// 打开界面
        /// </summary>
        /// <param name="windowType"></param>
        /// <returns></returns>
        public GameObject OpenWindow(int windowType)
        {
            WindowCfg info = null;

            WindowDict.TryGetValue(windowType, out info);
            WindowBase win;
            Dictionary <int, WindowBase> tempDict;

            if (info != null)
            {
                if (info.IsSingleton)
                {
                    if (OpenedWindowDict.TryGetValue(windowType, out tempDict))
                    {
                        if (tempDict.Count > 0)
                        {
                            tempDict.First().Value.ShowWidget();

                            return(tempDict.First().Value.gameObject);
                        }
                        else
                        {
                            win = CreateWindowByLayer(info.Layer, windowType);
                            tempDict.Add(win.WindowsId, win);
                        }
                    }
                    else
                    {
                        win = CreateWindowByLayer(info.Layer, windowType);
                        OpenedWindowDict.Add(windowType, new Dictionary <int, WindowBase>()
                        {
                            { win.WindowsId, win }
                        });
                    }
                }
                else
                {
                    win = CreateWindowByLayer(info.Layer, windowType);
                    if (OpenedWindowDict.TryGetValue(windowType, out tempDict))
                    {
                        tempDict.Add(win.WindowsId, win);
                    }
                    else
                    {
                        OpenedWindowDict.Add(windowType, new Dictionary <int, WindowBase>()
                        {
                            { win.WindowsId, win }
                        });
                    }
                }
                return(win.gameObject);
            }
            return(null);
        }