summaryrefslogtreecommitdiff
path: root/Other/NodeEditorExamples/Assets/xNode-examples/Examples/StateMachine/Nodes
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2022-06-28 09:40:37 +0800
committerchai <chaifix@163.com>2022-06-28 09:40:37 +0800
commit49b25e755b70ec412feaaf0b898d6f7e09d2bea6 (patch)
tree3c5f4260f30d1c2d7196db93153700d7ddec3157 /Other/NodeEditorExamples/Assets/xNode-examples/Examples/StateMachine/Nodes
parentc92269331692feca2c276649f6c4ee8911f1f859 (diff)
+node example
Diffstat (limited to 'Other/NodeEditorExamples/Assets/xNode-examples/Examples/StateMachine/Nodes')
-rw-r--r--Other/NodeEditorExamples/Assets/xNode-examples/Examples/StateMachine/Nodes/Editor.meta10
-rw-r--r--Other/NodeEditorExamples/Assets/xNode-examples/Examples/StateMachine/Nodes/Editor/StateNodeEditor.cs30
-rw-r--r--Other/NodeEditorExamples/Assets/xNode-examples/Examples/StateMachine/Nodes/Editor/StateNodeEditor.cs.meta13
-rw-r--r--Other/NodeEditorExamples/Assets/xNode-examples/Examples/StateMachine/Nodes/StateNode.cs39
-rw-r--r--Other/NodeEditorExamples/Assets/xNode-examples/Examples/StateMachine/Nodes/StateNode.cs.meta13
5 files changed, 105 insertions, 0 deletions
diff --git a/Other/NodeEditorExamples/Assets/xNode-examples/Examples/StateMachine/Nodes/Editor.meta b/Other/NodeEditorExamples/Assets/xNode-examples/Examples/StateMachine/Nodes/Editor.meta
new file mode 100644
index 00000000..cb4202f6
--- /dev/null
+++ b/Other/NodeEditorExamples/Assets/xNode-examples/Examples/StateMachine/Nodes/Editor.meta
@@ -0,0 +1,10 @@
+fileFormatVersion: 2
+guid: 61176f710e9af264db5db0a81711f423
+folderAsset: yes
+timeCreated: 1514506327
+licenseType: Free
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Other/NodeEditorExamples/Assets/xNode-examples/Examples/StateMachine/Nodes/Editor/StateNodeEditor.cs b/Other/NodeEditorExamples/Assets/xNode-examples/Examples/StateMachine/Nodes/Editor/StateNodeEditor.cs
new file mode 100644
index 00000000..f9d6b9eb
--- /dev/null
+++ b/Other/NodeEditorExamples/Assets/xNode-examples/Examples/StateMachine/Nodes/Editor/StateNodeEditor.cs
@@ -0,0 +1,30 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEditor;
+using UnityEngine;
+using XNode.Examples.StateGraph;
+
+namespace XNodeEditor.Examples {
+ [CustomNodeEditor(typeof(StateNode))]
+ public class StateNodeEditor : NodeEditor {
+
+ public override void OnHeaderGUI() {
+ GUI.color = Color.white;
+ StateNode node = target as StateNode;
+ StateGraph graph = node.graph as StateGraph;
+ if (graph.current == node) GUI.color = Color.blue;
+ string title = target.name;
+ GUILayout.Label(title, NodeEditorResources.styles.nodeHeader, GUILayout.Height(30));
+ GUI.color = Color.white;
+ }
+
+ public override void OnBodyGUI() {
+ base.OnBodyGUI();
+ StateNode node = target as StateNode;
+ StateGraph graph = node.graph as StateGraph;
+ if (GUILayout.Button("MoveNext Node")) node.MoveNext();
+ if (GUILayout.Button("Continue Graph")) graph.Continue();
+ if (GUILayout.Button("Set as current")) graph.current = node;
+ }
+ }
+} \ No newline at end of file
diff --git a/Other/NodeEditorExamples/Assets/xNode-examples/Examples/StateMachine/Nodes/Editor/StateNodeEditor.cs.meta b/Other/NodeEditorExamples/Assets/xNode-examples/Examples/StateMachine/Nodes/Editor/StateNodeEditor.cs.meta
new file mode 100644
index 00000000..e5414c99
--- /dev/null
+++ b/Other/NodeEditorExamples/Assets/xNode-examples/Examples/StateMachine/Nodes/Editor/StateNodeEditor.cs.meta
@@ -0,0 +1,13 @@
+fileFormatVersion: 2
+guid: f59d4dfd6e73e6b4d9d14256bc7a20f3
+timeCreated: 1514506333
+licenseType: Free
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
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
diff --git a/Other/NodeEditorExamples/Assets/xNode-examples/Examples/StateMachine/Nodes/StateNode.cs.meta b/Other/NodeEditorExamples/Assets/xNode-examples/Examples/StateMachine/Nodes/StateNode.cs.meta
new file mode 100644
index 00000000..04432757
--- /dev/null
+++ b/Other/NodeEditorExamples/Assets/xNode-examples/Examples/StateMachine/Nodes/StateNode.cs.meta
@@ -0,0 +1,13 @@
+fileFormatVersion: 2
+guid: 32ef86e1b73c7d642acaa1b75f66bbbb
+timeCreated: 1514505861
+licenseType: Free
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant: