1
0
mirror of https://github.com/Siccity/xNode.git synced 2026-03-26 22:49:02 +08:00
xNode/Samples~/MathGraph/Nodes/Editor/DisplayValueEditor.cs
Wang Cong 7b480b6242 changed: move folder Examples into Samples~
In Package Manager UI 2.0 (compatible with Unity 2019.1), you can include samples in a package.
    https://forum.unity.com/threads/samples-in-packages-manual-setup.623080/
2019-10-21 11:37:56 +08:00

27 lines
1.0 KiB
C#

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());
}
}
}