mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-20 17:26:02 +08:00
48 lines
1.6 KiB
C#
48 lines
1.6 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Reflection;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
namespace XNodeEditor {
|
|
/// <summary> Override graph inspector to show an 'Open Graph' button at the top </summary>
|
|
[CustomEditor(typeof(XNode.NodeGraph), true)]
|
|
public class GlobalGraphEditor : Editor {
|
|
public override void OnInspectorGUI() {
|
|
serializedObject.Update();
|
|
|
|
if (GUILayout.Button("Edit graph", GUILayout.Height(40))) {
|
|
NodeEditorWindow.Open(serializedObject.targetObject as XNode.NodeGraph);
|
|
}
|
|
|
|
GUILayout.Space(EditorGUIUtility.singleLineHeight);
|
|
GUILayout.Label("Raw data", "BoldLabel");
|
|
|
|
DrawDefaultInspector();
|
|
|
|
serializedObject.ApplyModifiedProperties();
|
|
}
|
|
}
|
|
|
|
[CustomEditor(typeof(XNode.Node), true)]
|
|
public class GlobalNodeEditor : Editor {
|
|
public override void OnInspectorGUI() {
|
|
serializedObject.Update();
|
|
|
|
if (GUILayout.Button("Edit graph", GUILayout.Height(40))) {
|
|
SerializedProperty graphProp = serializedObject.FindProperty("graph");
|
|
NodeEditorWindow w = NodeEditorWindow.Open(graphProp.objectReferenceValue as XNode.NodeGraph);
|
|
w.Home(); // Focus selected node
|
|
}
|
|
|
|
GUILayout.Space(EditorGUIUtility.singleLineHeight);
|
|
GUILayout.Label("Raw data", "BoldLabel");
|
|
|
|
// Now draw the node itself.
|
|
DrawDefaultInspector();
|
|
|
|
serializedObject.ApplyModifiedProperties();
|
|
}
|
|
}
|
|
} |