using System; using System.Collections; using System.Collections.Generic; using UnityEngine; namespace XED { public class TreeItem { public TwinObject twinObject; //public UI_HierarchyItem View; public event Action onDestroyTreeItem; public int depth { get { TreeItem curr = parent; int result = 0; while (curr != null) { result++; curr = curr.parent; } return result; } } public List children = new List(); public TreeItem parent; public bool expanded = true; public event Action onExpand; public event Action onFold; public TreeItem(TwinObject to) { twinObject = to; } internal void Add(TreeItem t) { children.Add(t); } internal void RemoveChild(TreeItem c) { children.Remove(c); } public void OnExpand(bool value) { expanded = value; if (value) onExpand?.Invoke(this); else onFold?.Invoke(this); } public void DestroyTreeItem() { onDestroyTreeItem?.Invoke(); } } }