Improved array UI

This commit is contained in:
Pascal Serrarens 2026-01-14 20:29:02 +01:00
parent 394df2167d
commit 78e750925d
2 changed files with 1466 additions and 12 deletions

View File

@ -217,21 +217,49 @@ public class ClusterInspector : Editor {
DrawSynapses(this.currentNucleus, position, size);
// Draw selected Nucleus
Handles.color = Color.white;
if (expandArray) {
float maxValue = 0;
foreach (INucleus nucleus in this.currentNucleus.array.nuclei) {
float value = length(nucleus.outputValue);
if (value > maxValue)
maxValue = value;
}
float spacing = 400f / this.currentNucleus.array.nuclei.Length;
float margin = 10 + spacing / 2;
float xMin = 150 - size;
float xMax = 150 + size;
float yMin = 10 + margin - size / 2;
float yMax = 400 - margin + size;
Vector3[] verts = new Vector3[4] {
new(xMin, yMin, 0),
new(xMax, yMin, 0),
new(xMax, yMax, 0),
new(xMin, yMax, 0)
};
Handles.color = Color.black;
Handles.DrawAAConvexPolygon(verts);
int row = 0;
foreach (INucleus nucleus in this.currentNucleus.array.nuclei) {
Vector3 pos = new(150, margin + row * spacing, 0.0f);
Handles.color = Color.white;
//Handles.DrawLine(parentPos, pos);
DrawNucleus(nucleus, pos, 0, size);
Handles.color = Color.white;
Handles.DrawSolidDisc(pos, Vector3.forward, size + 2);
DrawNucleus(nucleus, pos, maxValue, size);
row++;
}
GUIStyle style = new(EditorStyles.label) {
alignment = TextAnchor.UpperCenter,
normal = { textColor = Color.white },
fontStyle = FontStyle.Bold,
};
Vector3 labelPos = new Vector3(150, yMax, 0) - Vector3.down * (size + 0.2f); // below disc along up axis
Handles.Label(labelPos, this.currentNucleus.name, style);
}
else {
Handles.color = Color.white;
Handles.DrawSolidDisc(position, Vector3.forward, size + 2);
DrawNucleus(this.currentNucleus, position, length(this.currentNucleus.outputValue), 20);
}
@ -341,12 +369,6 @@ public class ClusterInspector : Editor {
if ((!expandArray || neuron.array.nuclei[0] != this.currentNucleus) && neuron.array.nuclei.Length > 1) {
Handles.Label(labelPosition, neuron.array.nuclei.Length.ToString(), style);
}
style.alignment = TextAnchor.UpperCenter;
Vector3 labelPos = position - Vector3.down * (size + 0.2f); // below disc along up axis
// if ((!expandArray || neuron.array.nuclei[0] != this.currentNucleus) && neuron.array.nuclei.Length > 1) {
// Handles.Label(labelPos, nucleus.name, style);
// }
// else {
if (expandArray && neuron.array.nuclei[0] == this.currentNucleus) {
int arrayIx = 0;
foreach (INucleus n in neuron.array.nuclei) {
@ -354,11 +376,14 @@ public class ClusterInspector : Editor {
break;
arrayIx++;
}
Handles.Label(labelPos, $"{nucleus.name}[{arrayIx}]", style);
Handles.Label(labelPosition, $"[{arrayIx}]", style);
}
else
else {
style.alignment = TextAnchor.UpperCenter;
Vector3 labelPos = position - Vector3.down * (size + 0.2f); // below disc along up axis
Handles.Label(labelPos, nucleus.name, style);
}
}
else {
style.alignment = TextAnchor.UpperCenter;
Vector3 labelPos = position - Vector3.down * (size + 0.2f); // below disc along up axis

File diff suppressed because it is too large Load Diff