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