using System; using System.Collections; using System.Collections.Generic; using System.Reflection; using UnityEditor; using UnityEngine; namespace XNodeEditor { /// Override graph inspector to show an 'Open Graph' button at the top [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.Open(graphProp.objectReferenceValue as XNode.NodeGraph); } GUILayout.Space(EditorGUIUtility.singleLineHeight); GUILayout.Label("Raw data", "BoldLabel"); // Now draw the node itself. DrawDefaultInspector(); serializedObject.ApplyModifiedProperties(); } } }