public override void OnCreateConnection(NodePort from, NodePort to) { base.OnCreateConnection(from, to); if (from.node != this) { if (from != null && (from.node.GetType() == typeof(AI_Cond_PlayerTime) || from.node.GetType() == typeof(AI_Cond_PlayerAniTime))) { triggleType = CnsStateTriggerType.AnimTime; } else if ((from != null) && (from.node.GetType() == typeof(AI_Cond_PlayerAniElem)) || (from.node.GetType() == typeof(AI_Cond_PlayerAnimElemTime))) { triggleType = CnsStateTriggerType.AnimElem; } if (from.node is AI_CreateStateDef) { DoCreateConnect(from, to, ref parent, "parent"); } else if (from.node is AI_BaseCondition) { DoCreateConnect(from, to, ref condition, "condition"); } else { var p1 = GetPort("parent"); var p2 = GetPort("condition"); from.Disconnect(p1); from.Disconnect(p2); } } }
public override void OnCreateConnection(NodePort from, NodePort to) { this.DisconnectIfNotType <TrainingExamplesNode, IFeatureIML>(from, to); // DIRTY CODE // InputFeatures size check if (to.fieldName == "InputFeatures") { // DIRTY CODE // Since there is a bug in DTW rapidlib, we don't allow features of different size connected // If we are a training examples node for DTW... if (this is SeriesTrainingExamplesNode) { // If we have any features... if (!Lists.IsNullOrEmpty(ref InputFeatures)) { // We check that the new feature connected is not of a different size int newFeatureSize = (from.node as IFeatureIML).FeatureValues.Values.Length; // Get the first feature connected as the template size int knownFeatureSize = (InputFeatures[0] as IFeatureIML).FeatureValues.Values.Length; // Disconnect if sizes don't match if (newFeatureSize != knownFeatureSize) { from.Disconnect(to); } } } } //if connected to target values if (to.fieldName == "TargetValues") { // Go through MLS systems connected if any MLS are classification or DTW set MLSclassification to true foreach (IMLConfiguration MLS in IMLConfigurationNodesConnected) { if (MLS.LearningType == IMLSpecifications.LearningType.DTW || MLS.LearningType == IMLSpecifications.LearningType.Classification) { MLSClassification = true; } } // if there is a mls classification connected and there is one or more target values break connection otherwise update list of connected wtarget values if (MLSClassification && TargetValues.Count >= 1) { from.Disconnect(to); } else { UpdateTargetValueInput(); } MLSClassification = false; } // if you have started training and this is not the system trying to stop you changing the connection and it is an output port if ((TrainingExamplesVector.Count > 0 || TrainingSeriesCollection.Count > 0) && from.IsInput && !badRemove) { from.Disconnect(to); } UpdateTargetValuesConfig(); inputPortList = this.GetInputPort("InputFeatures").GetConnections(); targetPortList = this.GetInputPort("TargetValues").GetConnections(); }
protected bool DoCreateConnect <T>(NodePort from, NodePort to, ref T item, string itemName, NodePort.IO dir = NodePort.IO.Input) where T : Node { // 不允许自己连接自己 if (from.node == to.node) { from.Disconnect(to); return(false); } if (dir == NodePort.IO.Input) { if (from.node == this) { return(false); } } else if (dir == NodePort.IO.Output) { if (from.node != this) { return(false); } } else { return(false); } if (dir == NodePort.IO.Input) { if (to.fieldName != itemName) { return(false); } item = from.node as T; } else if (dir == NodePort.IO.Output) { if (from.fieldName != itemName) { return(false); } item = from.node as T; } else { return(false); } if (item == null) { from.Disconnect(to); return(false); } return(true); }
public override void Disconnect(Edge edge) { // Copy the disconnect onto the linked data if (direction == Direction.Input) { target.Disconnect((edge.output as PortView).target); } else { target.Disconnect((edge.input as PortView).target); } base.Disconnect(edge); }
/// <summary> /// Disconnects two nodes if types don't match (3 type evaluation) /// </summary> public static bool DisconnectIfNotType <T, U, W>(this Node node, NodePort from, NodePort to) { // Check if types are matching bool isValidType1 = false; bool isValidType2 = false; bool disconnect = false; if (to.node is T) { isValidType1 = from.node is U; if (isValidType1) { // return here since we don't need to disconnect anything return(disconnect = false); } isValidType2 = from.node is W; if (isValidType2) { // return here since we don't need to disconnect anything return(disconnect = false); } // If we reach here, it is not a validType from.Disconnect(to); disconnect = true; } return(disconnect); }
/// <summary> /// Disconnect if at least not one of the types is found in the FROM node /// </summary> /// <param name="node"></param> /// <param name="from"></param> /// <param name="to"></param> /// <param name="typesAccepted"></param> /// <returns></returns> public static bool DisconnectFROMPortIsNotTypes(this Node node, NodePort from, NodePort to, Type[] typesAccepted) { bool disconnect = false; // If not types are passed, then do nothing if (typesAccepted == null || typesAccepted.Length < 1) { disconnect = false; return(disconnect); } bool typesEqual = false; // If one of the types is detected as equal, don't disconnect for (int i = 0; i < typesAccepted.Length; i++) { typesEqual = from.ValueType.Equals(typesAccepted); if (typesEqual) { disconnect = false; // End search return(disconnect); } } if (disconnect) { from.Disconnect(to); } return(disconnect); }
public void OnBeginDrag(PointerEventData eventData) { if (port.IsOutput) { tempConnection = Instantiate(graph.runtimeConnectionPrefab); tempConnection.transform.SetParent(graph.scrollRect.content); tempConnection.SetPosition(transform.position, eventData.position); startPos = transform.position; startPort = port; } else { if (port.IsConnected) { NodePort output = port.Connection; IUGUINode otherNode = graph.GetRuntimeNode(output.node); UGUIPort otherUGUIPort = otherNode.GetPort(output.fieldName, output.node); output.Disconnect(port); tempConnection = Instantiate(graph.runtimeConnectionPrefab); tempConnection.transform.SetParent(graph.scrollRect.content); tempConnection.SetPosition(otherUGUIPort.transform.position, eventData.position); startPos = otherUGUIPort.transform.position; startPort = otherUGUIPort.port; graph.GetRuntimeNode(node).UpdateGUI(); } } }
/// <summary> /// Override training Examples to only check for the single training examples type /// </summary> /// <param name="from"></param> /// <param name="to"></param> /// <param name="portName"></param> protected override void CheckTrainingExamplesConnections(NodePort from, NodePort to, string portName) { // Evaluate the nodeport for training examples if (to.fieldName == portName) { // Check if the node connected was a training examples node bool isNotTrainingExamplesNode = this.DisconnectIfNotType <CIMLConfiguration, SingleTrainingExamplesNode>(from, to); // If we broke the connection... if (isNotTrainingExamplesNode) { // Prepare flag to show error regarding training examples m_ErrorWrongInputTrainingExamplesPort = true; } // If we accept the connection... else { SingleTrainingExamplesNode examplesNode = from.node as SingleTrainingExamplesNode; if (examplesNode.TargetValues.Count > 1) { from.Disconnect(to); m_WrongNumberOfTargetValues = true; } // We check that the connection is from a training examples node if (examplesNode != null && !m_WrongNumberOfTargetValues) { // Update dynamic ports for output AddDynamicOutputPorts(examplesNode, ref m_DynamicOutputPorts); } } } }
public override void OnCreateConnection(NodePort from, NodePort to) { base.OnCreateConnection(from, to); if (from != null && from.node != this) { if (from != null && from.node.GetType() == typeof(AI_Cmd)) { if (DoCreateConnect <AI_Cmd> (from, to, ref input, "input")) { var pp = GetPort("prevCns"); if (pp != null) { pp.ClearConnections(); } } } else if (from != null && from.node.GetType() == typeof(AI_StateEvent_PlayCns)) { if (DoCreateConnect <AI_StateEvent_PlayCns> (from, to, ref prevCns, "prevCns")) { var pp = GetPort("input"); if (pp != null) { pp.ClearConnections(); } } } else { from.Disconnect(to); } } }
protected override void RemoveAt(TList collection, int index) { NodePort indexPort = GetNodePort(index); if (indexPort == null) { Debug.LogWarning($"No port found at index {index}"); } lastRemovedConnections.Clear(); if (indexPort != null) { lastRemovedConnections.AddRange(indexPort.GetConnections()); // Clear the removed ports connections indexPort.ClearConnections(); } // Cache the last port because I'm about to remove it NodePort lastPort = GetNodePort(ChildCount - 1); // Move following connections one step up to replace the missing connection for (int k = index + 1; k < ChildCount; k++) { NodePort kPort = GetNodePort(k); if (kPort == null) { continue; } NodePort k1Port = GetNodePort(k - 1); // Port k - 1 missing means I need to actually rename a port instead // Create k -1, add all the correct connections ... leave K alone because he existed if (k1Port == null) { k1Port = ReplaceNodeForRemove(k - 1); } for (int j = 0; j < kPort.ConnectionCount; j++) { NodePort other = kPort.GetConnection(j); kPort.Disconnect(other); k1Port.Connect(other); } } // Remove the last dynamic port, to avoid messing up the indexing if (lastPort != null) { lastPort.node.RemoveDynamicPort(lastPort); } base.RemoveAt(collection, index); this.ForceUpdateChildCount(); }
protected override void InsertAt(TList collection, int index, object value) { int newChildCount = this.ChildCount + 1; int nextId = this.ChildCount; // Remove happens before insert and we lose all the connections // Add a new port at the end if (nodePortInfo.Port.IsInput) { nodePortInfo.Node.AddDynamicInput(typeof(TElement), nodePortInfo.ConnectionType, nodePortInfo.TypeConstraint, string.Format("{0} {1}", nodePortInfo.BaseFieldName, nextId)); } else { nodePortInfo.Node.AddDynamicOutput(typeof(TElement), nodePortInfo.ConnectionType, nodePortInfo.TypeConstraint, string.Format("{0} {1}", nodePortInfo.BaseFieldName, nextId)); } // Move everything down to make space - if something is missing just pretend we moved it? for (int k = newChildCount - 1; k > index; --k) { NodePort k1Port = GetNodePort(k - 1); if (k1Port == null) // It is missing, I have nothing to move { continue; } for (int j = 0; j < k1Port.ConnectionCount; j++) { NodePort other = k1Port.GetConnection(j); k1Port.Disconnect(other); NodePort kPort = GetNodePort(k); if (kPort == null) { continue; } kPort.Connect(other); } } // Let's just re-add connections to this node that were probably his foreach (var c in lastRemovedConnections) { NodePort indexPort = GetNodePort(index); if (indexPort != null) { indexPort.Connect(c); } } lastRemovedConnections.Clear(); //if ( noDataResolver == null ) base.InsertAt(collection, index, value); this.ForceUpdateChildCount(); }
/// <summary>Draw node's body GUI.</summary> public override void OnBodyGUI() { base.OnBodyGUI(); _composite = target as BTCompositeNode; // Only work the GUI for the current exits and entries. int childCount = _composite.ChildCount; // Render children ports. EditorGUILayout.Space(); for (int i = 0; i < childCount; i++) { BTConnection connection = _composite.GetChildConnection(i); NodePort port = target.GetOutputPort(connection.PortName); NodePort connected = port.Connection; if (connected == null) { _composite.RemoveChildConnection(i); i--; childCount--; } else { GUILayout.BeginHorizontal(); EditorGUILayout.Space(); NodeEditorGUILayout.PortField(new GUIContent((i + 1).ToString()), port, GUILayout.Width(50)); GUILayout.EndHorizontal(); } } // Check if we need to create new exit. _newChild = target.GetOutputPort("newChild"); if (_newChild == null) { _newChild = target.AddInstanceOutput(typeof(BTConnection), Node.ConnectionType.Override, Node.TypeConstraint.Inherited, "newChild"); } // If exit connection is not empty create new exit. if (_newChild.Connection != null) { _composite.AddChildConnection(_newChild.Connection); _newChild.Disconnect(_newChild.Connection); } GUILayout.BeginHorizontal(); EditorGUILayout.Space(); NodeEditorGUILayout.PortField(_newChild, GUILayout.Width(80)); GUILayout.EndHorizontal(); }
/// <summary> /// Disconnects two nodes if types don't match /// </summary> /// <typeparam name="T">Type from</typeparam> /// <typeparam name="U">Type to</typeparam> /// <param name="node"></param> /// <param name="from"></param> /// <param name="to"></param> /// <returns>True if disconnected. False otherwise</returns> public static bool DisconnectIfNotType <T, U>(this Node node, NodePort from, NodePort to) { // Check if types are matching bool isValidType = false; if (to.node is T) { isValidType = from.node is U; if (!isValidType) { from.Disconnect(to); } } //True if disconnected.False otherwise return(!isValidType); }
public override void OnCreateConnection(NodePort from, NodePort to) { if (to.fieldName == nameof(Enumerable) && to.node == this) { ClearDynamicPorts(); ReflectionData reflectionData = GetInputValue <ReflectionData>(nameof(Enumerable)); if (typeof(IEnumerable).IsAssignableFrom(reflectionData.Type)) { Type type = reflectionData.Type.GetGenericArguments()[0]; _argumentTypeName = type.AssemblyQualifiedName; AddDynamicOutput(type, ConnectionType.Multiple, TypeConstraint.Inherited, type.Name); } else { from.Disconnect(to); } } }
/// <summary> /// Disconnect a Feature Extractor from a Data Type Node if the feature extracted doesn't match our expected type /// </summary> /// <typeparam name="T"></typeparam> /// <param name="node"></param> /// <param name="from"></param> /// <param name="to"></param> /// <param name="expectedType"></param> /// <returns></returns> public static bool DisconnectFeatureNotSameIMLDataType <T>(this BaseDataTypeNode <T> node, NodePort from, NodePort to, IMLSpecifications.DataTypes expectedType) { // Make sure that the feature connected is matching our type bool disconnect = false; // If it is a feature... if (from.node is IFeatureIML featureConnected) { // If it is a feature... if (featureConnected != null) { // Check that dataType is the same as the expected one if (featureConnected.FeatureValues.DataType != expectedType) { from.Disconnect(to); disconnect = true; } } } return(disconnect); }
/// <summary> /// Disconnects if ANY of the FROM port or node don't meet type requirements /// </summary> /// <param name="node"></param> /// <param name="from"></param> /// <param name="to"></param> /// <param name="typesPort"></param> /// <param name="typesNode"></param> /// <returns></returns> public static bool DisconnectPortAndNodeIfANYTypes(this Node node, NodePort from, NodePort to, Type[] typesPort, Type[] typesNode) { // Init equals bool equalPorts = true; bool equalNodeType = true; // If null or empty, allow connections // Port Types if (typesPort == null && typesPort.Length < 1) { equalPorts = false; } else { equalPorts = CheckPortEqualTypes(node, from, to, typesPort); } // Node Types if (typesNode == null && typesNode.Length < 1) { equalNodeType = false; } else { equalNodeType = CheckNodeEqualTypes(node, from, to, typesNode); } // If any of them is true, DO disconnect if (equalPorts || equalNodeType) { from.Disconnect(to); return(true); } // If all of them are false, DON'T disconnect else { return(false); } }
/// <summary> /// Disconnect two IML Data Types if they are not equal /// </summary> /// <typeparam name="T"></typeparam> /// <param name="node"></param> /// <param name="from"></param> /// <param name="to"></param> /// <param name="expectedType"></param> /// <returns></returns> public static bool DisconnectIfNotSameIMLDataType <T>(this BaseDataTypeNode <T> node, NodePort from, NodePort to, IMLSpecifications.DataTypes expectedType) { // Make sure that the IMLDataType connected is matching our type bool disconnect = false; // If it is a IMLDataType, check that it is the exact same one if (from.node.GetType().Equals(typeof(IMLBaseDataType))) { var featureConnected = from.node as IFeatureIML; // If it is a feature... if (featureConnected != null) { // Check that dataType is the same as the expected one if (featureConnected.FeatureValues.DataType != expectedType) { from.Disconnect(to); disconnect = true; } } } return(disconnect); }
public void UpdateConnectionTransforms() { if (port.IsInput) { return; } while (connections.Count < port.ConnectionCount) { AddConnection(); } while (connections.Count > port.ConnectionCount) { Destroy(connections[0].gameObject); connections.RemoveAt(0); } // Loop through connections for (int i = port.ConnectionCount - 1; i >= 0; i--) { NodePort other = port.GetConnection(i); IUGUINode otherNode = graph.GetRuntimeNode(other.node); if (otherNode == null) { Debug.LogWarning(other.node.name + " node not found ||| " + other.node, this); port.Disconnect(i); continue; } Transform port2 = otherNode.GetPort(other.fieldName, other.node).transform; if (!port2) { Debug.LogWarning(other.fieldName + " not found", this); } connections[i].SetPosition(transform.position, port2.position); } }
/// <summary> /// Disconnects two nodes if two Data Type Nodes are not exactly the same /// </summary> /// <typeparam name="T"></typeparam> /// <param name="node"></param> /// <param name="from"></param> /// <param name="to"></param> /// <returns></returns> public static bool DisconnectIfNotSameDataTypeNode <T> (this BaseDataTypeNode <T> node, NodePort from, NodePort to) { bool disconnect = false; // Check if types are matching Type nodeConnectedType = from.node.GetType(); // Check if the from node is a dataType var isDataType = ReusableMethods.Types.IsSubclassOfRawGeneric(typeof(BaseDataTypeNode <>), nodeConnectedType); // If it is a dataType... if (isDataType) { // Check if both from and to are the same dataType var isSameType = nodeConnectedType.Equals(node.GetType()); // If not (i.e. a float vs a Vector3) if (!isSameType) { // We disconnect the nodes from.Disconnect(to); disconnect = true; } } return(disconnect); }
public void Controls() { wantsMouseMove = true; Event e = Event.current; switch (e.type) { case EventType.MouseMove: break; case EventType.ScrollWheel: if (e.delta.y > 0) { zoom += 0.1f * zoom; } else { zoom -= 0.1f * zoom; } break; case EventType.MouseDrag: if (e.button == 0) { if (IsDraggingPort) { if (IsHoveringPort && hoveredPort.IsInput) { if (!draggedOutput.IsConnectedTo(hoveredPort)) { draggedOutputTarget = hoveredPort; } } else { draggedOutputTarget = null; } Repaint(); } else if (IsDraggingNode) { draggedNode.position = WindowToGridPosition(e.mousePosition) + dragOffset; Repaint(); } } else if (e.button == 1) { panOffset += e.delta * zoom; isPanning = true; } break; case EventType.KeyDown: if (GUIUtility.keyboardControl == 0) { break; } else if (e.keyCode == KeyCode.F) { Home(); } break; case EventType.MouseDown: Repaint(); if (e.button == 0) { SelectNode(hoveredNode); if (IsHoveringPort) { if (hoveredPort.IsOutput) { draggedOutput = hoveredPort; } else { hoveredPort.VerifyConnections(); if (hoveredPort.IsConnected) { Node node = hoveredPort.node; NodePort output = hoveredPort.Connection; hoveredPort.Disconnect(output); draggedOutput = output; draggedOutputTarget = hoveredPort; if (NodeEditor.onUpdateNode != null) { NodeEditor.onUpdateNode(node); } } } } else if (IsHoveringNode && IsHoveringTitle(hoveredNode)) { draggedNode = hoveredNode; dragOffset = hoveredNode.position - WindowToGridPosition(e.mousePosition); } } break; case EventType.MouseUp: if (e.button == 0) { //Port drag release if (IsDraggingPort) { //If connection is valid, save it if (draggedOutputTarget != null) { Node node = draggedOutputTarget.node; if (graph.nodes.Count != 0) { draggedOutput.Connect(draggedOutputTarget); } if (NodeEditor.onUpdateNode != null) { NodeEditor.onUpdateNode(node); } EditorUtility.SetDirty(graph); } //Release dragged connection draggedOutput = null; draggedOutputTarget = null; EditorUtility.SetDirty(graph); Repaint(); AssetDatabase.SaveAssets(); } else if (IsDraggingNode) { draggedNode = null; AssetDatabase.SaveAssets(); } else if (GUIUtility.hotControl != 0) { AssetDatabase.SaveAssets(); } } else if (e.button == 1) { if (!isPanning) { ShowContextMenu(); } isPanning = false; } break; } }
public void Controls() { wantsMouseMove = true; Event e = Event.current; switch (e.type) { case EventType.MouseMove: UpdateHovered(); break; case EventType.ScrollWheel: if (e.delta.y > 0) { zoom += 0.1f * zoom; } else { zoom -= 0.1f * zoom; } break; case EventType.MouseDrag: UpdateHovered(); if (e.button == 0) { if (IsDraggingPort) { if (IsHoveringPort && hoveredPort.IsInput) { if (!draggedOutput.IsConnectedTo(hoveredPort)) { draggedOutputTarget = hoveredPort; } } else { draggedOutputTarget = null; } Repaint(); } else if (IsDraggingNode) { draggedNode.rect.position = WindowToGridPosition(e.mousePosition) + dragOffset; Repaint(); } } else if (e.button == 1) { panOffset += e.delta * zoom; isPanning = true; } break; case EventType.KeyDown: if (e.keyCode == KeyCode.F) { Home(); } break; case EventType.MouseDown: UpdateHovered(); Repaint(); SelectNode(hoveredNode); if (IsHoveringPort) { if (hoveredPort.IsOutput) { draggedOutput = hoveredPort; } else { if (hoveredPort.IsConnected) { NodePort output = hoveredPort.Connection; hoveredPort.Disconnect(output); draggedOutput = output; draggedOutputTarget = hoveredPort; } } } else if (IsHoveringNode && IsHoveringTitle(hoveredNode)) { draggedNode = hoveredNode; dragOffset = hoveredNode.rect.position - WindowToGridPosition(e.mousePosition); } break; case EventType.MouseUp: if (e.button == 0) { //Port drag release if (IsDraggingPort) { //If connection is valid, save it if (draggedOutputTarget != null) { if (graph.nodes.Count != 0) { draggedOutput.Connect(draggedOutputTarget); } } //Release dragged connection draggedOutput = null; draggedOutputTarget = null; Repaint(); } else if (IsDraggingNode) { draggedNode = null; } } else if (e.button == 1) { if (!isPanning) { ShowContextMenu(); } isPanning = false; } UpdateHovered(); break; } }
protected bool DoCreateConnectToList <T>(NodePort from, NodePort to, ref List <T> condList, string condListName, NodePort.IO dir = NodePort.IO.Input) where T : Node { // 不允许自己连接自己 if (from.node == to.node) { from.Disconnect(to); return(false); } if (dir == NodePort.IO.Input) { if (from.node == this) { return(false); } } else if (dir == NodePort.IO.Output) { if (from.node != this) { return(false); } } else { return(false); } T item = default(T); if (dir == NodePort.IO.Input) { if (to.fieldName != condListName) { return(false); } item = from.node as T; } else if (dir == NodePort.IO.Output) { if (from.fieldName != condListName) { return(false); } item = from.node as T; } else { return(false); } if (item != null) { if (condList == null) { condList = new List <T> (); } T cc = from.node as T; if (!condList.Contains(cc)) { condList.Add(cc); } return(true); } else { from.Disconnect(to); } return(false); }
/// <summary>Draw transition ports.</summary> protected virtual void OnTransitionsGUI() { _state = target as FSMStateNode; // Only work the GUI for the current exits and entries. int exitCount = _state.ExitsCount; int entryCount = _state.EntriesCount; // Check if we need to create new entry. _entry = target.GetInputPort("entry"); if (_entry == null) { _entry = target.AddInstanceInput(typeof(FSMConnection), Node.ConnectionType.Override, Node.TypeConstraint.Inherited, "entry"); } // If entry connection is not empty create new entry. if (_entry.Connection != null) { _state.AddEntryConnection(_entry.Connection); _entry.Disconnect(_entry.Connection); } // Check if we need to create new exit. _exit = target.GetOutputPort("exit"); if (_exit == null) { _exit = target.AddInstanceOutput(typeof(FSMConnection), Node.ConnectionType.Override, Node.TypeConstraint.Inherited, "exit"); } // If exit connection is not empty create new exit. if (_exit.Connection != null) { _state.AddExitConnection(_exit.Connection); _exit.Disconnect(_exit.Connection); } GUILayout.BeginHorizontal(); NodeEditorGUILayout.PortField(_entry, GUILayout.Width(50)); EditorGUILayout.Space(); NodeEditorGUILayout.PortField(_exit, GUILayout.Width(50)); GUILayout.EndHorizontal(); EditorGUILayout.Space(); for (int i = 0; i < entryCount; i++) { FSMConnection connection = _state.GetEntryConnection(i); NodePort port = target.GetInputPort(connection.PortName); NodePort connected = port.Connection; if (connected == null) { _state.RemoveEntryConnection(i); i--; entryCount--; } else { GUILayout.BeginHorizontal(); NodeEditorGUILayout.PortField(new GUIContent(), port, GUILayout.Width(-4)); EditorGUILayout.LabelField(string.Format("> {0}", connected.node.name)); GUILayout.EndHorizontal(); } } EditorGUILayout.Space(); for (int i = 0; i < exitCount; i++) { FSMConnection connection = _state.GetExitConnection(i); NodePort port = target.GetOutputPort(connection.PortName); NodePort connected = port.Connection; if (connected == null) { _state.RemoveExitConnection(i); i--; exitCount--; } else { GUILayout.BeginHorizontal(); EditorGUILayout.Space(); NodeEditorGUILayout.PortField(new GUIContent(), port, GUILayout.Width(50)); GUILayout.EndHorizontal(); } } }
private void DrawStateNode(int maxChildCount) { int childCount = _FTNode.ChildCount; for (int i = 0; i < childCount; i++) { FTConnection connection = _FTNode.GetChildConnection(i); NodePort port = target.GetOutputPort(connection.portName); NodePort connected = port.Connection; if (connected == null) { _FTNode.RemoveChildConnection(i); i--; childCount--; } else { //GUILayout.BeginArea(new Rect(50f, 50f + i * 100f, 100f, 100f)); EditorGUILayout.BeginVertical("Box"); { EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); NodeEditorGUILayout.PortField(new GUIContent("To" + (i + 1)), port, GUILayout.Width(50)); EditorGUILayout.EndHorizontal(); // GUILayout.Button("XXX"); var fsms = FTUtils.GetFSMTransitionMethod("ActorFSM"); List <string> names = new List <string>(); foreach (var tp in fsms) { names.Add(tp.ToString()); } EditorGUILayout.Popup(0, names.ToArray()); } EditorGUILayout.EndVertical(); //GUILayout.EndArea(); } } // if (NodeEditorWindow.mode == NodeEditorMode.Edit && childCount < maxChildCount) if (childCount < maxChildCount) { _outputNewChild = target.GetOutputPort(OUTPUT_PORT_NEWCHILD); if (_outputNewChild == null) { _outputNewChild = target.AddDynamicOutput(typeof(FTConnection), Node.ConnectionType.Override, Node.TypeConstraint.Inherited, OUTPUT_PORT_NEWCHILD); } if (_outputNewChild.Connection != null) { _FTNode.AddChildConnection(_outputNewChild.Connection); _outputNewChild.Disconnect(_outputNewChild.Connection); EditorUtility.SetDirty(target); } GUILayout.BeginHorizontal(); EditorGUILayout.Space(); NodeEditorGUILayout.PortField(_outputNewChild, GUILayout.Width(80)); GUILayout.EndHorizontal(); } }