Cleanup
This commit is contained in:
parent
790deab7c6
commit
278b861a84
@ -24,44 +24,7 @@ public class ClusterInspector : Editor {
|
|||||||
serializedObject.Update();
|
serializedObject.Update();
|
||||||
|
|
||||||
VisualElement root = new();
|
VisualElement root = new();
|
||||||
//GraphView graph =
|
|
||||||
CreateInspector(root, cluster);
|
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();
|
serializedObject.ApplyModifiedProperties();
|
||||||
return root;
|
return root;
|
||||||
@ -98,34 +61,11 @@ public class ClusterInspector : Editor {
|
|||||||
mainContainer.Add(inspectorContainer);
|
mainContainer.Add(inspectorContainer);
|
||||||
root.Add(mainContainer);
|
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);
|
graph.SetGraph(null, cluster, cluster.output, inspectorContainer);
|
||||||
|
|
||||||
return graph;
|
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 {
|
public class GraphView : VisualElement {
|
||||||
ClusterPrefab cluster;
|
ClusterPrefab cluster;
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEditor.UIElements;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UIElements;
|
using UnityEngine.UIElements;
|
||||||
|
|
||||||
@ -18,7 +17,6 @@ public class NanoBrainComponent_Editor : Editor {
|
|||||||
|
|
||||||
if (Application.isPlaying == false)
|
if (Application.isPlaying == false)
|
||||||
brainProp = serializedObject.FindProperty(nameof(NanoBrain.defaultBrain));
|
brainProp = serializedObject.FindProperty(nameof(NanoBrain.defaultBrain));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override VisualElement CreateInspectorGUI() {
|
public override VisualElement CreateInspectorGUI() {
|
||||||
@ -29,73 +27,11 @@ public class NanoBrainComponent_Editor : Editor {
|
|||||||
|
|
||||||
|
|
||||||
VisualElement root = new();
|
VisualElement root = new();
|
||||||
//ClusterInspector.GraphView board =
|
|
||||||
ClusterInspector.CreateInspector(root, brain.prefab);
|
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)
|
if (Application.isPlaying == false)
|
||||||
serializedObject.ApplyModifiedProperties();
|
serializedObject.ApplyModifiedProperties();
|
||||||
return root;
|
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
|
|
||||||
// // }
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user