Mercurial > hg > Database > jungle-sharp
changeset 19:0865819106cf
add mapping code.
author | Kazuma |
---|---|
date | Mon, 05 Dec 2016 05:28:53 +0900 |
parents | faa8a0c1492e |
children | 1f99e150f336 |
files | src/main/csharp/jp.ac.u-ryukyu.ie.cr/ObjectMapper/SceneNode.cs |
diffstat | 1 files changed, 45 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/csharp/jp.ac.u-ryukyu.ie.cr/ObjectMapper/SceneNode.cs Mon Dec 05 05:28:53 2016 +0900 @@ -0,0 +1,45 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class SceneNode : MonoBehaviour { + + public GameObject obj; + + public SceneNode m_parent; + public System.Collections.Generic.List<SceneNode> m_childs; + + public SceneNode(GameObject obj, SceneNode parent=null){ + this.obj = obj; + 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(); + } +}