public NodeWindow(NodeEditorObject nodeObj) { var ohBehave = EditorWindow.GetWindow <OhBehaveEditorWindow>(); treeBlueprint = ohBehave.treeBlueprint; nodeObject = nodeObj; nodeName = nodeObj.displayName; switch (nodeObj.nodeType) { case NodeType.Leaf: nodeStyle = OhBehaveEditorWindow.LeafNodeStyle; bgColor = NodeStyle.LeafColor; labelStyle = NodeStyle.LeafLabelStyle; break; case NodeType.Selector: nodeStyle = OhBehaveEditorWindow.SelectorNodeStyle; bgColor = NodeStyle.SelectorColor; labelStyle = NodeStyle.SelectorLabelStyle; outPoint = new ConnectionPoint(this, ConnectionPointType.Out, ConnectionControls.OnClickOutPoint); break; case NodeType.Sequence: nodeStyle = OhBehaveEditorWindow.SequenceNodeStyle; bgColor = NodeStyle.SequenceColor; labelStyle = NodeStyle.SequencerLabelStyle; outPoint = new ConnectionPoint(this, ConnectionPointType.Out, ConnectionControls.OnClickOutPoint); break; case NodeType.Inverter: nodeStyle = OhBehaveEditorWindow.InverterNodeStyle; bgColor = NodeStyle.InverterColor; labelStyle = NodeStyle.InverterLabelStyle; outPoint = new ConnectionPoint(this, ConnectionPointType.Out, ConnectionControls.OnClickOutPoint); break; } currentStyle = nodeStyle.defaultStyle; if (nodeObject.index != OhBehaveTreeBlueprint.ROOT_INDEX) { inPoint = new ConnectionPoint(this, ConnectionPointType.In, ConnectionControls.OnClickInPoint); } NodeEditorObject prntObj = nodeObject.Parent; if (prntObj != null) { parent = (IParentNodeWindow)prntObj.GetWindow(); if (parent == null) { refreshConnection = true; } } else { bgColor = NodeStyle.RootColor; } }
public void SetParentWindow(IParentNodeWindow newParent) { if (parent != null) { // TODO: cleanup old connection throw new Exception("Must handle situation where child already has parent!"); } parent = newParent; }
public void ParentRemoved() { if (parent == null) { return; } parent = null; }
protected void RefreshConnection() { NodeEditorObject prntObj = nodeObject.Parent; if (prntObj != null) { parent = (IParentNodeWindow)prntObj.GetWindow(); if (parent != null) { refreshConnection = false; } } }
/// <summary> /// Called when Remove Connection selected from context menu. /// </summary> private void DisconnectParent(IParentNodeWindow parent) { NodeEditorObject.DisconnectNodes(((NodeWindow)parent).nodeObject, nodeWindow.nodeObject); }