Mercurial > hg > Database > jungle-sharp
view Main/ObjectMapper/SceneNode.cs @ 41:bd44baa491a9 default tip
add TestJungleCore.cs
author | Kazuma Takeda |
---|---|
date | Thu, 23 Feb 2017 17:19:55 +0900 |
parents | e954d456665c |
children |
line wrap: on
line source
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<SceneNode> 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<SceneNode>(); } 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(); } } }