public KC_TreeNode(KC_TreeNode parent) { // Set the parent and add this node to the children of the parent. // fixme: remove // Parent = parent; parent?.AddChild(this); Children = new List <KC_TreeNode>(); }
public static void SetTreeParent(this Unit unit, KC_TreeNode parent) { if (unit.HasComponent <KC_TreeNode>()) { parent.AddChild(unit.GetComponent <KC_TreeNode>()); } else { throw new InvalidOperationException("SetTreeParent() called on Unit without a KC_TreeNode componenent."); } }
public KC_TreeNode(KC_TreeNode parent, IList <KC_TreeNode> children) { // Set the Parent and add this node to the children of the parent // fixme: remove // Parent = parent; parent?.AddChild(this); // Set the Children and set the parent of each of the children to this node Children = children; foreach (KC_TreeNode child in children) { child.Parent = this; } }
public static void SetTreeChildren(this Unit unit, IList <KC_TreeNode> children) { if (unit.HasComponent <KC_TreeNode>()) { KC_TreeNode thisNode = unit.GetComponent <KC_TreeNode>(); // First remove any existing children. thisNode.RemoveChildren(); // Now add each new child to the node foreach (KC_TreeNode child in children) { thisNode.AddChild(child); } } else { throw new InvalidOperationException("SetTreeChildren() called on Unit without a KC_TreeNode componenent."); } }