/// <summary> /// 销毁 /// </summary> public void Dispose() { for (int i = 0, ci = _nodeObjects.Count; i < ci; ++i) { var node = _nodeObjects[i]; ObjectPool.Release(ref node); } _data = null; _tree = null; _resLoaded = false; _enable = false; }
/// <summary> /// 初始化 /// </summary> public void Init(SceneTree tree, SceneTreeNodeData data) { _tree = tree; _data = data; int nCapacity = data.objects.Length; _nodeObjects.Capacity = nCapacity; for (int i = 0; i < nCapacity; ++i) { // 对于草四叉树来说 nCapacity 根 _data.instances.Length 是一样的 var node = ObjectPool.New <SceneTreeNodeObject>(); int idxPrefab = _data.instances.Length <= 0 ? -1 : i < _data.instances.Length ? _data.instances[i].prefabId : -1; node.Init(_tree, _data.objects[i], idxPrefab); _nodeObjects.Add(node); } }