Esempio n. 1
0
        /// <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);
            }));
        }
Esempio n. 2
0
        /// <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);
            }));
        }
Esempio n. 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);
        }