Exemplo n.º 1
0
        /// <summary>
        /// 加载场景中的静态物体
        /// </summary>
        /// <param name="_sceneName"></param>
        /// <param name="_centerPoint"></param>
        /// <param name="_completeCalback">完成事件回调</param>
        /// <param name="_cacheCurrent">是否缓存当前场景,这是一个高速加载的机制,用空间换时间,在3G内存以上的机器上有效</param>
        public void LoadStaticItems(string _sceneName, Vector3 _centerPoint, Action _completeCalback = null, bool _cacheCurrent = false)
        {
            if (DeviceInfo.GetMemorySize() < 3) // 3G内存下,不考虑缓存
            {
                _cacheCurrent = false;
            }

            LoadSceneStaticConfig(_sceneName, info =>
            {
                if (info.ItemSerializeds.Count > 0)
                {
                    SceneStaticItemLoader sceneLoader = null;
                    if (false == SceneStaticItemLoadersDict.TryGetValue(_sceneName, out sceneLoader))
                    {
                        sceneLoader = new SceneStaticItemLoader(_sceneName, info);
                        SceneStaticItemLoadersDict.Add(_sceneName, sceneLoader);
                    }

                    if (null != sceneLoader)
                    {
                        sceneLoader.StartFramingInstatiate(_centerPoint, _completeCalback);
                        currentShowSceneLoader = sceneLoader;
                    }
                }
                else
                {
                    this.Error("静态物体数量为空");
                }
            });
        }
Exemplo n.º 2
0
        /// <summary>
        /// 卸载一个场景
        /// </summary>
        /// <param name="_sceneName"></param>
        /// <param name="_complete"></param>
        public void UnloadScene(string _sceneName, Action _complete = null)
        {
            SceneStaticItemLoader sceneStaticItemLoader = null;

            if (true == SceneStaticItemLoadersDict.TryGetValue(_sceneName, out sceneStaticItemLoader))
            {
                sceneStaticItemLoader.Dispose(() =>
                {
                    this.Debug("场景卸载完成 = " + _sceneName);
                    if (null != _complete)
                    {
                        _complete();
                    }
                });

                SceneStaticItemLoadersDict.Remove(_sceneName);
            }
        }