From 49b25e755b70ec412feaaf0b898d6f7e09d2bea6 Mon Sep 17 00:00:00 2001 From: chai Date: Tue, 28 Jun 2022 09:40:37 +0800 Subject: +node example --- .../StateMachine/Nodes/Editor/StateNodeEditor.cs | 30 ++++++++++++++++++++++ .../Nodes/Editor/StateNodeEditor.cs.meta | 13 ++++++++++ 2 files changed, 43 insertions(+) create mode 100644 Other/NodeEditorExamples/Assets/xNode-examples/Examples/StateMachine/Nodes/Editor/StateNodeEditor.cs create mode 100644 Other/NodeEditorExamples/Assets/xNode-examples/Examples/StateMachine/Nodes/Editor/StateNodeEditor.cs.meta (limited to 'Other/NodeEditorExamples/Assets/xNode-examples/Examples/StateMachine/Nodes/Editor') 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: -- cgit v1.1-26-g67d0