/// <summary> /// 场景加载完成 /// </summary> static void OnLoadSceneComplete(ResBase res) { if (SceneDesc.current == null) { return; } if (null != _sceneDesc) { Debug.LogErrorFormat("Load scene {0} repeat!", _sceneName); DestroyScene(); } _sceneDesc = SceneDesc.current; ResManager.InitGrass(_sceneDesc.prefabs); if (null != _sceneDesc) { for (int i = 0; i < _sceneDesc.trees.Length; ++i) { var tree = ObjectPool.New <SceneTree>(); tree.Init(_sceneDesc.trees[i]); _trees.Add(tree); } // ResCollection _resCollection = ObjectPool.New <ResCollection>(); _resCollection.Init(_sceneDesc.resCollection); _resCollection.LoadRes(); } }
/// <summary> /// 创建 /// </summary> void Awake() { if (null != Instance) { Debug.LogError("More than one SceneDesc in scene!"); return; } Instance = this; }
/// <summary> /// 销毁场景 /// </summary> static public void DestroyScene() { for (int i = 0, ci = _trees.Count; i < ci; ++i) { var tree = _trees[i]; ObjectPool.Release(ref tree); } _trees.Clear(); _sceneName = null; _sceneDesc = null; _frustum = null; ObjectPool.Release(ref _resCollection); ResManager.Release(ref _resScene); }
/// <summary> /// 销毁 /// </summary> void OnDestroy() { Instance = null; }