public override void OnHeaderGUI() { GUI.color = Color.white; StateNode node = target as StateNode; StateMachineGraph graph = node.graph as StateMachineGraph; if (graph.currentState == node) { GUI.color = Color.red; } if (graph.defaultState == node) { GUI.color = Color.blue; } if (graph.defaultState == node && graph.currentState == node) { GUI.color = Color.cyan; } string title = target.name; GUILayout.Label(title, NodeEditorResources.styles.nodeHeader, GUILayout.Height(30)); GUI.color = Color.white; }
private void MoveNextImmediateState(Node connectingNode) { if (connectingNode is StateNode) { StateNode node = connectingNode as StateNode; StateMachineGraph fsmGraph = graph as StateMachineGraph; fsmGraph.TransitionToState(node); } }
/// <summary> /// Finds the owner of our state machine if one exists. /// </summary> /// <param name="fsmgraph"></param> private void FindOwner_Editor(StateMachineGraph fsmgraph) { var stateMachines = GameObject.FindObjectsOfType <StateMachine>(); for (int i = 0; i < stateMachines.Length; i++) { if (stateMachines[i].CompareCurrentGraph(fsmgraph)) { fsmgraph.SetStateMachineOwner(stateMachines[i].gameObject); } } }
public void OnEnter() { StateMachineGraph fsmGraph = graph as StateMachineGraph; if (this.thisState != null) { GameObject owner = fsmGraph.GetStateMachineOwner(); if (owner != null) { this.thisState.OnEnterState(owner); } } }
public override void OnBodyGUI() { base.OnBodyGUI(); StateNode node = target as StateNode; StateMachineGraph fsmgraph = node.graph as StateMachineGraph; if (fsmgraph.GetStateMachineOwner() == null) { FindOwner_Editor(fsmgraph); } if (GUILayout.Button("Proceed State")) { fsmgraph.NextState(); } if (GUILayout.Button("Set as default state")) { node.name = "Starting State"; fsmgraph.defaultState = node; } }
public void MoveNext() { StateMachineGraph fsmGraph = graph as StateMachineGraph; if (fsmGraph.currentState != this) { Debug.LogError("This node is not the current one."); return; } NodePort exitPort = GetPort("exitState"); if (!exitPort.IsConnected) { Debug.LogError("State exit port is not connected"); return; } MoveNextImmediateState(exitPort.Connection.node); MoveNextTransition(exitPort.Connection.node); MoveNextForwarded(exitPort.Connection.node); }