public BTEditorGraphNode OnInsertChild(int index, BehaviourNode node) { if (node != null && ((m_node is Composite) || (m_node is Decorator))) { BTEditorGraphNode graphNode = null; if (m_node is Composite) { Composite composite = m_node as Composite; composite.InsertChild(index, node); graphNode = BTEditorGraphNode.CreateExistingNode(this, node); m_children.Insert(index, graphNode); } else if (m_node is Decorator) { Decorator decorator = m_node as Decorator; DestroyChildren(); decorator.SetChild(node); graphNode = BTEditorGraphNode.CreateExistingNode(this, node); m_children.Add(graphNode); } BTEditorCanvas.Current.RecalculateSize(node.Position); return(graphNode); } return(null); }
private void SetExistingNode(BehaviourNode node) { DestroyChildren(); m_node = node; m_isSelected = false; if (node is Composite) { Composite composite = node as Composite; for (int i = 0; i < composite.ChildCount; i++) { BehaviourNode childNode = composite.GetChild(i); BTEditorGraphNode graphNode = BTEditorGraphNode.CreateExistingNode(this, childNode); m_children.Add(graphNode); } } else if (node is Decorator) { Decorator decorator = node as Decorator; BehaviourNode childNode = decorator.GetChild(); if (childNode != null) { BTEditorGraphNode graphNode = BTEditorGraphNode.CreateExistingNode(this, childNode); m_children.Add(graphNode); } } }