This commit is contained in:
Pascal Serrarens 2026-02-06 17:33:07 +01:00
parent 790deab7c6
commit 278b861a84
2 changed files with 0 additions and 124 deletions

View File

@ -24,44 +24,7 @@ public class ClusterInspector : Editor {
serializedObject.Update();
VisualElement root = new();
//GraphView graph =
CreateInspector(root, cluster);
// root.style.paddingLeft = 0;
// root.style.paddingRight = 0;
// root.style.paddingTop = 0;
// root.style.paddingBottom = 0;
// root.styleSheets.Add(Resources.Load<StyleSheet>("GraphStyles"));
// mainContainer = new() {
// style = {
// height = 450
// }
// };
// GraphView graph = new();
// graph.style.flexGrow = 1;
// inspectorContainer = new VisualElement {
// name = "inspector"
// };
// mainContainer.Add(graph);
// mainContainer.Add(inspectorContainer);
// root.Add(mainContainer);
// // Run once for initial state (use resolved style width if available)
// float initialWidth = root.layout.width > 0 ? root.layout.width : root.contentRect.width;
// UpdateLayout(initialWidth);
// // React to size changes of root (or parent if appropriate)
// root.RegisterCallback<GeometryChangedEvent>(evt => {
// UpdateLayout(evt.newRect.width);
// });
//graph.SetGraph(null, cluster, cluster.output, inspectorContainer);
// else
// Debug.LogWarning(" No brain!");
serializedObject.ApplyModifiedProperties();
return root;
@ -98,34 +61,11 @@ public class ClusterInspector : Editor {
mainContainer.Add(inspectorContainer);
root.Add(mainContainer);
// Run once for initial state (use resolved style width if available)
float initialWidth = root.layout.width > 0 ? root.layout.width : root.contentRect.width;
//UpdateLayout(initialWidth);
// React to size changes of root (or parent if appropriate)
// root.RegisterCallback<GeometryChangedEvent>(evt => {
// UpdateLayout(evt.newRect.width);
// });
graph.SetGraph(null, cluster, cluster.output, inspectorContainer);
return graph;
}
private static void UpdateLayout(float containerWidth) {
// if (containerWidth > 600f) {
// mainContainer.style.flexDirection = FlexDirection.Row;
// inspectorContainer.style.width = 300; // fixed sidebar width
// inspectorContainer.style.flexGrow = 0;
// }
// else {
// mainContainer.style.flexDirection = FlexDirection.Column;
// inspectorContainer.style.width = Length.Percent(100); // full width below
// inspectorContainer.style.flexDirection = FlexDirection.Column;
// inspectorContainer.style.flexGrow = 1; // can set 0 or keep as needed
// }
}
public class GraphView : VisualElement {
ClusterPrefab cluster;

View File

@ -1,5 +1,4 @@
using UnityEditor;
using UnityEditor.UIElements;
using UnityEngine;
using UnityEngine.UIElements;
@ -18,7 +17,6 @@ public class NanoBrainComponent_Editor : Editor {
if (Application.isPlaying == false)
brainProp = serializedObject.FindProperty(nameof(NanoBrain.defaultBrain));
}
public override VisualElement CreateInspectorGUI() {
@ -29,73 +27,11 @@ public class NanoBrainComponent_Editor : Editor {
VisualElement root = new();
//ClusterInspector.GraphView board =
ClusterInspector.CreateInspector(root, brain.prefab);
// root.style.paddingLeft = 0;
// root.style.paddingRight = 0;
// root.style.paddingTop = 0;
// root.style.paddingBottom = 0;
// root.styleSheets.Add(Resources.Load<StyleSheet>("GraphStyles"));
// if (Application.isPlaying == false) {
// PropertyField brainField = new(brainProp) {
// label = "Nano Brain"
// };
// root.Add(brainField);
// }
// mainContainer = new() {
// name = "main",
// style = {
// height = 450,
// }
// };
// board = new ClusterInspector.GraphView();
// board.style.flexGrow = 1;
// mainContainer.Add(board);
// inspectorContainer = new VisualElement {
// name = "inspector"
// // style = {
// // width = 400,
// // }
// };
// mainContainer.Add(inspectorContainer);
// root.Add(mainContainer);
// // Run once for initial state (use resolved style width if available)
// float initialWidth = root.layout.width > 0 ? root.layout.width : root.contentRect.width;
// UpdateLayout(initialWidth);
// // React to size changes of root (or parent if appropriate)
// root.RegisterCallback<GeometryChangedEvent>(evt => {
// UpdateLayout(evt.newRect.width);
// });
// if (brain != null && board != null)
// board.SetGraph(component.gameObject, brain.prefab, brain.output, inspectorContainer);
// else
// Debug.LogWarning(" No brain!");
if (Application.isPlaying == false)
serializedObject.ApplyModifiedProperties();
return root;
}
// private void UpdateLayout(float containerWidth) {
// // if (containerWidth > 800f) {
// mainContainer.style.flexDirection = FlexDirection.Row;
// inspectorContainer.style.width = 300; // fixed sidebar width
// inspectorContainer.style.flexGrow = 0;
// // }
// // else {
// // mainContainer.style.flexDirection = FlexDirection.Column;
// // inspectorContainer.style.width = Length.Percent(100); // full width below
// // inspectorContainer.style.flexDirection = FlexDirection.Column;
// // inspectorContainer.style.flexGrow = 1; // can set 0 or keep as needed
// // }
// }
}