From 49b25e755b70ec412feaaf0b898d6f7e09d2bea6 Mon Sep 17 00:00:00 2001 From: chai Date: Tue, 28 Jun 2022 09:40:37 +0800 Subject: +node example --- .../Examples/StateMachine/Nodes/StateNode.cs | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Other/NodeEditorExamples/Assets/xNode-examples/Examples/StateMachine/Nodes/StateNode.cs (limited to 'Other/NodeEditorExamples/Assets/xNode-examples/Examples/StateMachine/Nodes/StateNode.cs') diff --git a/Other/NodeEditorExamples/Assets/xNode-examples/Examples/StateMachine/Nodes/StateNode.cs b/Other/NodeEditorExamples/Assets/xNode-examples/Examples/StateMachine/Nodes/StateNode.cs new file mode 100644 index 00000000..2bb7dc03 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/xNode-examples/Examples/StateMachine/Nodes/StateNode.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace XNode.Examples.StateGraph { + public class StateNode : Node { + + [Input] public Empty enter; + [Output] public Empty exit; + + public void MoveNext() { + StateGraph fmGraph = graph as StateGraph; + + if (fmGraph.current != this) { + Debug.LogWarning("Node isn't active"); + return; + } + + NodePort exitPort = GetOutputPort("exit"); + + if (!exitPort.IsConnected) { + Debug.LogWarning("Node isn't connected"); + return; + } + + StateNode node = exitPort.Connection.node as StateNode; + node.OnEnter(); + } + + public void OnEnter() { + StateGraph fmGraph = graph as StateGraph; + fmGraph.current = this; + } + + [Serializable] + public class Empty { } + } +} \ No newline at end of file -- cgit v1.1-26-g67d0