Improved array UI
This commit is contained in:
parent
394df2167d
commit
78e750925d
@ -217,21 +217,49 @@ public class ClusterInspector : Editor {
|
|||||||
DrawSynapses(this.currentNucleus, position, size);
|
DrawSynapses(this.currentNucleus, position, size);
|
||||||
|
|
||||||
// Draw selected Nucleus
|
// Draw selected Nucleus
|
||||||
Handles.color = Color.white;
|
|
||||||
if (expandArray) {
|
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 spacing = 400f / this.currentNucleus.array.nuclei.Length;
|
||||||
float margin = 10 + spacing / 2;
|
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;
|
int row = 0;
|
||||||
foreach (INucleus nucleus in this.currentNucleus.array.nuclei) {
|
foreach (INucleus nucleus in this.currentNucleus.array.nuclei) {
|
||||||
Vector3 pos = new(150, margin + row * spacing, 0.0f);
|
Vector3 pos = new(150, margin + row * spacing, 0.0f);
|
||||||
Handles.color = Color.white;
|
Handles.color = Color.white;
|
||||||
//Handles.DrawLine(parentPos, pos);
|
//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++;
|
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 {
|
else {
|
||||||
|
Handles.color = Color.white;
|
||||||
Handles.DrawSolidDisc(position, Vector3.forward, size + 2);
|
Handles.DrawSolidDisc(position, Vector3.forward, size + 2);
|
||||||
DrawNucleus(this.currentNucleus, position, length(this.currentNucleus.outputValue), 20);
|
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) {
|
if ((!expandArray || neuron.array.nuclei[0] != this.currentNucleus) && neuron.array.nuclei.Length > 1) {
|
||||||
Handles.Label(labelPosition, neuron.array.nuclei.Length.ToString(), style);
|
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) {
|
if (expandArray && neuron.array.nuclei[0] == this.currentNucleus) {
|
||||||
int arrayIx = 0;
|
int arrayIx = 0;
|
||||||
foreach (INucleus n in neuron.array.nuclei) {
|
foreach (INucleus n in neuron.array.nuclei) {
|
||||||
@ -354,10 +376,13 @@ public class ClusterInspector : Editor {
|
|||||||
break;
|
break;
|
||||||
arrayIx++;
|
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);
|
Handles.Label(labelPos, nucleus.name, style);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
style.alignment = TextAnchor.UpperCenter;
|
style.alignment = TextAnchor.UpperCenter;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user