diff options
author | chai <chaifix@163.com> | 2022-06-28 09:40:37 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2022-06-28 09:40:37 +0800 |
commit | 49b25e755b70ec412feaaf0b898d6f7e09d2bea6 (patch) | |
tree | 3c5f4260f30d1c2d7196db93153700d7ddec3157 /Other/NodeEditorExamples/Assets/xNode-examples/Examples/MathGraph/Nodes/Editor | |
parent | c92269331692feca2c276649f6c4ee8911f1f859 (diff) |
+node example
Diffstat (limited to 'Other/NodeEditorExamples/Assets/xNode-examples/Examples/MathGraph/Nodes/Editor')
2 files changed, 40 insertions, 0 deletions
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 { + + /// <summary> + /// 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. + /// </summary> + [CustomNodeEditor(typeof(DisplayValue))] + public class DisplayValueEditor : NodeEditor { + + /// <summary> Called whenever the xNode editor window is updated </summary> + 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: |