コード例 #1
0
        private void Init(GameViewConfig gameViewConfig, Transform parent)
        {
            Config = gameViewConfig;

            UIparent = parent;

            ConfigViewDictionary = new Dictionary <string, GameViewInfo>();

            ViewDictionary = new List <GameViewAbstract>();

            if (Config == null)
            {
                return;
            }

            ConfigViewDictionary = Config.GetViewWithDic();

            foreach (string item in ConfigViewDictionary.Keys)
            {
                if (ConfigViewDictionary[item].isCache)
                {
                    GameViewAbstract game = CreateView(item);
                    game.gameObject.SetActive(false);
                    ViewDictionary.Add(game);
                }
            }
            if (Config.DefaultViewTable != null && Config.DefaultViewTable != "")
            {
                OpenView(Config.DefaultViewTable);
            }
        }
コード例 #2
0
        /// <summary>
        /// 打开指定页面
        /// </summary>
        /// <param name="table"></param>
        /// <param name="isSinge"></param>
        /// <returns></returns>
        public GameViewAbstract OpenView(string table, bool isSinge = false)
        {
            int viewCount = getViewIndex(table, isSinge);

            if (viewCount != -1)
            {
                ViewDictionary[viewCount].isOpen = true;
                ViewDictionary[viewCount].gameObject.SetActive(true);
                ViewDictionary[viewCount].transform.SetAsLastSibling();
                ViewDictionary[viewCount].OnOpenView();
                return(ViewDictionary[viewCount]);
            }
            else if (ConfigViewDictionary.ContainsKey(table))
            {
                GameViewAbstract gameViewAbstract = CreateView(table);
                gameViewAbstract.isOpen = true;
                gameViewAbstract.gameObject.SetActive(true);
                gameViewAbstract.transform.SetAsLastSibling();
                gameViewAbstract.OnOpenView();
                ViewDictionary.Add(gameViewAbstract);
                return(gameViewAbstract);
            }
            else
            {
                Debug.LogFormat("<color=yellow>{0}</color>", "GameViewManager : 打开view失败,未找到指定table --- " + table);
                return(null);
            }
        }
コード例 #3
0
        public T OpenView <T>(string table, bool isSinge = false) where T : GameViewAbstract
        {
            GameViewAbstract view = OpenView(table, isSinge);

            if (view != null)
            {
                return(view as T);
            }
            return(null);
        }
コード例 #4
0
        /// <summary>
        /// 关闭所有页面 并打开指定页面
        /// </summary>
        /// <param name="table"></param>
        /// <returns></returns>
        public GameViewAbstract OpenViewAndCloseOther(string table, bool isSinge)
        {
            if (table == null)
            {
                return(null);
            }

            foreach (var item in ViewDictionary)
            {
                item.CloseView();
            }

            GameViewAbstract view = OpenView(table, isSinge);

            return(view);
        }
コード例 #5
0
        /// <summary>
        /// 构建一个View对象
        /// </summary>
        /// <param name="Table">ViewTable</param>
        /// <returns></returns>
        private GameViewAbstract CreateView(string Table)
        {
            GameViewAbstract gameViewAbstract = GameObject.Instantiate <GameViewAbstract>(ConfigViewDictionary[Table].View, UIparent);

            gameViewAbstract.VIEWTABLE = Table;
            if (ConfigViewDictionary[Table].isOnce)
            {
                gameViewAbstract.isOnce = ConfigViewDictionary[Table].isOnce;
            }
            else
            {
                gameViewAbstract.isOnce = ContainsKeyView(Table);
            }
            gameViewAbstract.SetViewManager(this);
            gameViewAbstract.isOpen = false;
            gameViewAbstract.OnInitView();
            return(gameViewAbstract);
        }