public static void DeleteNode(Node node, BehaviorTrees bt) { if (node.parentNode != null) { node.parentNode.childNodes = ArrayUtility.Remove <Node>(node.parentNode.childNodes, node); } foreach (Node child in node.childNodes) { if (child != null) { child.parentNode = null; } } if (node.decorators.Length > 0) { foreach (Decorator decorator in node.decorators) { BehaviorTreesEditorUtility.DeleteDecorator(decorator); } } if (node is Composite && (node as Composite).services.Length > 0) { foreach (Service service in (node as Composite).services) { BehaviorTreesEditorUtility.DeleteService(service); } } bt.nodes = ArrayUtility.Remove <Node>(bt.nodes, node); BehaviorTreesEditorUtility.DestroyImmediate(node); }
public static void DeleteService(Service service) { service.parent.services = ArrayUtility.Remove <Service>(service.parent.services, service); BehaviorTreesEditorUtility.DestroyImmediate(service); }
public static void DeleteDecorator(Decorator decorator) { decorator.parent.decorators = ArrayUtility.Remove <Decorator>(decorator.parent.decorators, decorator); BehaviorTreesEditorUtility.DestroyImmediate(decorator); }