20
|
1 using System.Collections;
|
|
2 using System.Collections.Generic;
|
|
3 using UnityEngine;
|
|
4 using System;
|
|
5 namespace JungleDB {
|
|
6 [Serializable]
|
|
7 public class SceneNode {
|
|
8
|
|
9 public GameObject obj;
|
|
10 public string Name;
|
|
11
|
|
12 public SceneNode m_parent;
|
|
13
|
|
14 [SerializeField]
|
|
15 public System.Collections.Generic.List<SceneNode> m_childs;
|
|
16
|
|
17 public SceneNode(GameObject obj, SceneNode parent=null){
|
|
18 this.obj = obj;
|
|
19 this.Name = obj.name;
|
|
20 m_parent = parent;
|
|
21 m_childs = new System.Collections.Generic.List<SceneNode>();
|
|
22 }
|
|
23
|
|
24 public void OnAdded () {}
|
|
25
|
|
26 public void OnRemoved () {}
|
|
27
|
|
28 public bool AddChild (SceneNode toAdd){
|
|
29 toAdd.m_parent = this;
|
|
30 m_childs.Add(toAdd);
|
|
31 toAdd.OnAdded();
|
|
32 return true;
|
|
33 }
|
|
34
|
|
35 public bool RemoveChild (SceneNode toRemove) {
|
|
36 toRemove.OnRemoved();
|
|
37 return m_childs.Remove(toRemove);
|
|
38 }
|
|
39
|
|
40 public void RemoveAllChildren () {
|
|
41 int childcount = m_childs.Count;
|
|
42 for(int i = 0; i < childcount ;++i){
|
|
43 m_childs[i].RemoveAllChildren();
|
|
44 }
|
|
45
|
|
46 for(int i = 0; i < childcount ;++i){
|
|
47 m_childs[i].OnRemoved();
|
|
48 }
|
|
49 m_childs.Clear();
|
|
50 }
|
|
51 }
|
|
52 } |