예제 #1
0
        /// <inheritdoc cref="IUIDataController.PrecacheSceneUI"/>
        public IPromise PrecacheSceneUI(string sceneName)
        {
            Promise promise = new Promise();

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

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

            if (_precachedSceneGraph.ContainsKey(sceneName))
            {
                promise.Resolve();
                return(promise);
            }

            return(_viewHandler.PrecacheViews(graph).Then(() =>
            {
                _precachedSceneGraph.Add(sceneName, graph);
            }));
        }