using System.Collections; using System.Collections.Generic; using UnityEngine; using System; namespace JungleDB { [Serializable] public class SceneNode { public GameObject obj; public string Name; public SceneNode m_parent; [SerializeField] public System.Collections.Generic.List m_childs; public SceneNode(GameObject obj, SceneNode parent=null){ this.obj = obj; this.Name = obj.name; m_parent = parent; m_childs = new System.Collections.Generic.List(); } public void OnAdded () {} public void OnRemoved () {} public bool AddChild (SceneNode toAdd){ toAdd.m_parent = this; m_childs.Add(toAdd); toAdd.OnAdded(); return true; } public bool RemoveChild (SceneNode toRemove) { toRemove.OnRemoved(); return m_childs.Remove(toRemove); } public void RemoveAllChildren () { int childcount = m_childs.Count; for(int i = 0; i < childcount ;++i){ m_childs[i].RemoveAllChildren(); } for(int i = 0; i < childcount ;++i){ m_childs[i].OnRemoved(); } m_childs.Clear(); } } }