From 49b25e755b70ec412feaaf0b898d6f7e09d2bea6 Mon Sep 17 00:00:00 2001 From: chai Date: Tue, 28 Jun 2022 09:40:37 +0800 Subject: +node example --- .../MathGraph/Nodes/Editor/DisplayValueEditor.cs | 27 ++++++++++++++++++++++ .../Nodes/Editor/DisplayValueEditor.cs.meta | 13 +++++++++++ 2 files changed, 40 insertions(+) create mode 100644 Other/NodeEditorExamples/Assets/xNode-examples/Examples/MathGraph/Nodes/Editor/DisplayValueEditor.cs create mode 100644 Other/NodeEditorExamples/Assets/xNode-examples/Examples/MathGraph/Nodes/Editor/DisplayValueEditor.cs.meta (limited to 'Other/NodeEditorExamples/Assets/xNode-examples/Examples/MathGraph/Nodes/Editor') diff --git a/Other/NodeEditorExamples/Assets/xNode-examples/Examples/MathGraph/Nodes/Editor/DisplayValueEditor.cs b/Other/NodeEditorExamples/Assets/xNode-examples/Examples/MathGraph/Nodes/Editor/DisplayValueEditor.cs new file mode 100644 index 00000000..706c5dc2 --- /dev/null +++ b/Other/NodeEditorExamples/Assets/xNode-examples/Examples/MathGraph/Nodes/Editor/DisplayValueEditor.cs @@ -0,0 +1,27 @@ +using UnityEditor; +using XNode.Examples.MathNodes; + +namespace XNodeEditor.Examples { + + /// + /// NodeEditor functions similarly to the Editor class, only it is xNode specific. + /// Custom node editors should have the CustomNodeEditor attribute that defines which node type it is an editor for. + /// + [CustomNodeEditor(typeof(DisplayValue))] + public class DisplayValueEditor : NodeEditor { + + /// Called whenever the xNode editor window is updated + public override void OnBodyGUI() { + + // Draw the default GUI first, so we don't have to do all of that manually. + base.OnBodyGUI(); + + // `target` points to the node, but it is of type `Node`, so cast it. + DisplayValue displayValueNode = target as DisplayValue; + + // Get the value from the node, and display it + object obj = displayValueNode.GetValue(); + if (obj != null) EditorGUILayout.LabelField(obj.ToString()); + } + } +} \ No newline at end of file diff --git a/Other/NodeEditorExamples/Assets/xNode-examples/Examples/MathGraph/Nodes/Editor/DisplayValueEditor.cs.meta b/Other/NodeEditorExamples/Assets/xNode-examples/Examples/MathGraph/Nodes/Editor/DisplayValueEditor.cs.meta new file mode 100644 index 00000000..971da18a --- /dev/null +++ b/Other/NodeEditorExamples/Assets/xNode-examples/Examples/MathGraph/Nodes/Editor/DisplayValueEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 7d7298690665789498dc42a285eb2c28 +timeCreated: 1509305659 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: -- cgit v1.1-26-g67d0