diff Main/ObjectMapper/SceneNode.cs @ 20:1f99e150f336

fix folder and add Object Mapper.
author Kazuma Takeda
date Thu, 15 Dec 2016 22:52:48 +0900
parents
children e954d456665c
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Main/ObjectMapper/SceneNode.cs	Thu Dec 15 22:52:48 2016 +0900
@@ -0,0 +1,52 @@
+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();
+		}
+	}
+}
\ No newline at end of file