blob: 706c5dc2434401b2cbe573a138cb2e0967f42243 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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());
}
}
}
|