using UnityEditor; using UnityEditor.UIElements; using UnityEngine; using UnityEngine.UIElements; namespace NanoBrain { [CustomEditor(typeof(Brain))] public class NanoBrainComponent_Editor : Editor { protected static VisualElement mainContainer; protected static VisualElement inspectorContainer; protected Brain component; private SerializedProperty brainProp; //ClusterInspector.GraphView board; public void OnEnable() { component = target as Brain; if (Application.isPlaying == false && serializedObject != null) { string propertyName = nameof(Brain.defaultBrain); brainProp = serializedObject.FindProperty(propertyName); } } public override VisualElement CreateInspectorGUI() { Cluster brain = component.brain; if (Application.isPlaying == false) serializedObject.Update(); VisualElement root = new(); if (Application.isPlaying == false) { PropertyField brainField = new(brainProp) { label = "Cluster Prefab" }; root.Add(brainField); } if (brain != null) ClusterInspector.CreateInspector(root, brain.prefab, brain.defaultOutput, component.gameObject); if (Application.isPlaying == false) serializedObject.ApplyModifiedProperties(); return root; } } }