Exemplo n.º 1
0
 private static void Unattach(this TreeHierarchyNodeAsset self, TreeHierarchyNodeAsset child)
 {
     Debug.Assert(self._children.Contains(child));
     self._children.Remove(child);
     child._isFloating = true;
     child._tree._floaters.Add(child);
 }
Exemplo n.º 2
0
 public static void DeleteHierarchy(this TreeHierarchyNodeAsset self)
 {
     if (self._parent != null)
     {
         self.UnattachFromParent();
     }
     foreach (var node in self.Postorder())
     {
         GameObject.DestroyImmediate(self, true);
     }
 }
Exemplo n.º 3
0
        public static void ChangeParentTo(this TreeHierarchyNodeAsset child, TreeHierarchyNodeAsset newParent)
        {
            Debug.Assert(newParent._tree == child._tree);

            if (child._parent != null)
            {
                child._parent.Unattach(child);
            }

            child._parent = newParent;
            newParent._children.Add(child);
            child._isFloating = false;
            child._tree._floaters.Remove(child);
        }
Exemplo n.º 4
0
        public static void ChangeParentTo(this TreeHierarchyNodeAsset child, TreeHierarchyNodeAsset newParent, int index)
        {
            Debug.Assert(newParent._tree == child._tree);
            if (child._parent == newParent && index > newParent._children.IndexOf(child))
            {
                index--;
            }

            if (child._parent != null)
            {
                child._parent.Unattach(child);
            }

            child._parent = newParent;
            newParent._children.Insert(index, child);
            child._isFloating = false;
            child._tree._floaters.Remove(child);
        }
Exemplo n.º 5
0
 public static void UnattachFromParent(this TreeHierarchyNodeAsset child)
 {
     child._parent.Unattach(child);
 }
Exemplo n.º 6
0
 public static void ChangeParentTo(this TreeHierarchyNodeAsset child, TreeHierarchyNodeAsset newParent)
 {
     ChangeParentTo(child, newParent, newParent._children.Count);
 }