NanoBrain-unitypackage/Editor/NanoBrain_Editor.cs
Pascal Serrarens 04ca8dda07 Squashed 'NanoBrain/' content from commit b3423b9
git-subtree-dir: NanoBrain
git-subtree-split: b3423b99a752cdabbc4e7c51565fb54425481feb
2026-03-09 11:10:53 +01:00

49 lines
1.4 KiB
C#

using UnityEditor;
using UnityEditor.UIElements;
using UnityEngine;
using UnityEngine.UIElements;
[CustomEditor(typeof(NanoBrain))]
public class NanoBrainComponent_Editor : Editor {
protected static VisualElement mainContainer;
protected static VisualElement inspectorContainer;
protected NanoBrain component;
private SerializedProperty brainProp;
ClusterInspector.GraphView board;
public void OnEnable() {
component = target as NanoBrain;
if (Application.isPlaying == false && serializedObject != null) {
string propertyName = nameof(NanoBrain.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 = "Nano Brain"
};
root.Add(brainField);
}
if (brain != null)
ClusterInspector.CreateInspector(root, brain.prefab, brain.defaultOutput, component.gameObject);
if (Application.isPlaying == false)
serializedObject.ApplyModifiedProperties();
return root;
}
}