Physics ant

This commit is contained in:
Pascal Serrarens 2026-02-10 10:08:35 +01:00
parent 76c5372089
commit fd7359acd0
2 changed files with 7 additions and 5 deletions

View File

@ -24,13 +24,13 @@ public class ClusterInspector : Editor {
serializedObject.Update(); serializedObject.Update();
VisualElement root = new(); VisualElement root = new();
CreateInspector(root, prefab, prefab.output); CreateInspector(root, prefab, prefab.output, null);
serializedObject.ApplyModifiedProperties(); serializedObject.ApplyModifiedProperties();
return root; return root;
} }
public static GraphView CreateInspector(VisualElement root, ClusterPrefab cluster, Nucleus output) { public static GraphView CreateInspector(VisualElement root, ClusterPrefab cluster, Nucleus output, GameObject gameObject) {
root.style.paddingLeft = 0; root.style.paddingLeft = 0;
root.style.paddingRight = 0; root.style.paddingRight = 0;
root.style.paddingTop = 0; root.style.paddingTop = 0;
@ -61,7 +61,7 @@ public class ClusterInspector : Editor {
mainContainer.Add(inspectorContainer); mainContainer.Add(inspectorContainer);
root.Add(mainContainer); root.Add(mainContainer);
graph.SetGraph(null, output, inspectorContainer); graph.SetGraph(gameObject, output, inspectorContainer);
return graph; return graph;
} }
@ -593,7 +593,8 @@ public class ClusterInspector : Editor {
Vector3 value = synapse.nucleus.outputValue * synapse.weight; Vector3 value = synapse.nucleus.outputValue * synapse.weight;
GUIContent synapseValueLabel = new(synapse.nucleus.name, synapse.nucleus.outputValue.ToString()); GUIContent synapseValueLabel = new(synapse.nucleus.name, synapse.nucleus.outputValue.ToString());
EditorGUILayout.FloatField(synapseValueLabel, length(synapse.nucleus.outputValue)); EditorGUILayout.FloatField(synapseValueLabel, length(synapse.nucleus.outputValue));
} else { }
else {
EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField(synapse.nucleus.name); EditorGUILayout.LabelField(synapse.nucleus.name);
if (GUILayout.Button("Disconnect")) if (GUILayout.Button("Disconnect"))
@ -671,6 +672,7 @@ public class ClusterInspector : Editor {
void OnSceneGUI(SceneView sceneView) { void OnSceneGUI(SceneView sceneView) {
if (this.gameObject != null) { if (this.gameObject != null) {
Vector3 worldVector = this.gameObject.transform.TransformVector(this.currentNucleus.outputValue); Vector3 worldVector = this.gameObject.transform.TransformVector(this.currentNucleus.outputValue);
// worldVector = worldVector.normalized;
Handles.color = Color.yellow; Handles.color = Color.yellow;
Handles.DrawLine(this.gameObject.transform.position, this.gameObject.transform.position + worldVector); Handles.DrawLine(this.gameObject.transform.position, this.gameObject.transform.position + worldVector);
} }

View File

@ -27,7 +27,7 @@ public class NanoBrainComponent_Editor : Editor {
VisualElement root = new(); VisualElement root = new();
ClusterInspector.CreateInspector(root, brain.prefab, brain.output); ClusterInspector.CreateInspector(root, brain.prefab, brain.output, component.gameObject);
if (Application.isPlaying == false) if (Application.isPlaying == false)
serializedObject.ApplyModifiedProperties(); serializedObject.ApplyModifiedProperties();