コード例 #1
0
ファイル: ViewHandler.cs プロジェクト: SheepBros/UISystem
        /// <inheritdoc cref="IViewHandler.PrecacheViews"/>
        public IPromise PrecacheViews(UISceneGraph sceneGraph)
        {
            if (_precaching.Contains(sceneGraph))
            {
                Promise promise = new Promise();
                promise.Resolve();
                return(promise);
            }

            List <UIElement> list = new List <UIElement>();

            foreach (var pair in sceneGraph.UIElements)
            {
                if (pair.Value.Precache && !_precachedViews.ContainsKey(pair.Value))
                {
                    list.Add(pair.Value);
                }
            }

            _precaching.Add(sceneGraph);

            return(InstantiateViews(list, _canvasForPrecaching, (element, vieObject) =>
            {
                vieObject.SetActive(false);
                _precachedViews.Add(element, vieObject);
            }).Then(() =>
            {
                _precaching.Remove(sceneGraph);
            }));
        }
コード例 #2
0
ファイル: UIController.cs プロジェクト: SheepBros/UISystem
        /// <inheritdoc cref="IUIController.ChangeSceneGraph"/>
        public IPromise ChangeSceneGraph(string sceneName, bool precacheIfNot = true)
        {
            Promise promise = new Promise();

            if (!_dataController.IsLoaded())
            {
                promise.Fail(new Exception("UISystem is not initialized"));
                return(promise);
            }

            if (!_dataController.TryGetSceneGraph(sceneName, out UISceneGraph graph))
            {
                promise.Fail(new Exception($"There is no graph for {sceneName} scene."));
                return(promise);
            }

            return(_dataController.PrecacheSceneUI(sceneName).Then(() =>
            {
                _screenStack.Clear();
                _currentScreen = null;
                _currentGraph = graph;

                UIScreenNode startNode = _currentGraph.GetStartNode();
                RequestScreen(startNode.Name).Then(promise.Resolve);
            }));
        }
コード例 #3
0
        /// <inheritdoc cref="IUIDataController.TryGetSceneGraph"/>
        public bool TryGetSceneGraph(string sceneName, out UISceneGraph graph)
        {
            if (_sceneList.SceneGraphs.TryGetValue(sceneName, out graph))
            {
                return(true);
            }

            return(false);
        }