Fix labels
This commit is contained in:
parent
885d649be1
commit
9cbf0aaa2c
@ -326,6 +326,19 @@ public class ClusterInspector : Editor {
|
|||||||
DrawNucleus(nucleus, pos, maxValue, size);
|
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(150, yMax + size + 5, 0);
|
||||||
|
int colonPos = receptor1.name.IndexOf(":");
|
||||||
|
if (colonPos > 0) {
|
||||||
|
string baseName = receptor1.name[..colonPos];
|
||||||
|
Handles.Label(labelPos, baseName, style);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Handles.Label(labelPos, receptor1.name, style);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -415,9 +428,6 @@ public class ClusterInspector : Editor {
|
|||||||
Handles.DrawLine(parentPos, pos);
|
Handles.DrawLine(parentPos, pos);
|
||||||
if (synapse.nucleus != null) {
|
if (synapse.nucleus != null) {
|
||||||
Color color = Color.black;
|
Color color = Color.black;
|
||||||
// if (synapse.nucleus.isSleeping)
|
|
||||||
// color = Color.darkRed;
|
|
||||||
// else
|
|
||||||
if (Application.isPlaying) {
|
if (Application.isPlaying) {
|
||||||
float brightness = length(synapse.nucleus.outputValue) * synapse.weight / maxValue;
|
float brightness = length(synapse.nucleus.outputValue) * synapse.weight / maxValue;
|
||||||
color = new Color(brightness, brightness, brightness, 1f);
|
color = new Color(brightness, brightness, brightness, 1f);
|
||||||
@ -430,17 +440,12 @@ public class ClusterInspector : Editor {
|
|||||||
|
|
||||||
private void DrawNucleus(Nucleus nucleus, Vector3 position, float maxValue, float size) {
|
private void DrawNucleus(Nucleus nucleus, Vector3 position, float maxValue, float size) {
|
||||||
Color color;
|
Color color;
|
||||||
// if (nucleus.isSleeping)
|
if (Application.isPlaying) {
|
||||||
// color = Color.darkRed;
|
float brightness = length(nucleus.outputValue) / maxValue;
|
||||||
// else
|
color = new Color(brightness, brightness, brightness, 1f);
|
||||||
{
|
|
||||||
if (Application.isPlaying) {
|
|
||||||
float brightness = length(nucleus.outputValue) / maxValue;
|
|
||||||
color = new Color(brightness, brightness, brightness, 1f);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
color = Color.black;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
color = Color.black;
|
||||||
DrawNucleus(nucleus, position, maxValue, size, color);
|
DrawNucleus(nucleus, position, maxValue, size, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -468,37 +473,35 @@ public class ClusterInspector : Editor {
|
|||||||
receptor1.array = new NucleusArray(nucleus);
|
receptor1.array = new NucleusArray(nucleus);
|
||||||
|
|
||||||
if ((!expandArray || receptor1.array.nuclei.First() != this.currentNucleus) && receptor1.array.nuclei.Count() > 1) {
|
if ((!expandArray || receptor1.array.nuclei.First() != this.currentNucleus) && receptor1.array.nuclei.Count() > 1) {
|
||||||
Handles.Label(labelPosition, receptor1.array.nuclei.Count().ToString(), style);
|
if (color.grayscale > 0.5f)
|
||||||
|
style.normal.textColor = Color.black;
|
||||||
|
else
|
||||||
|
style.normal.textColor = Color.white;
|
||||||
|
Handles.Label(labelPosition, receptor1.array.nuclei.Length.ToString(), style);
|
||||||
|
style.normal.textColor = Color.white;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nucleus is ReceptorArray receptor) {
|
// if (nucleus is ReceptorArray receptor) {
|
||||||
Handles.Label(labelPosition, receptor.instances.Count().ToString(), style);
|
// if (color.grayscale > 0.5f)
|
||||||
}
|
// style.normal.textColor = Color.black;
|
||||||
// else if (nucleus is ReceptorInstance receptorI) {
|
// else
|
||||||
// if (expandArray) {
|
// style.normal.textColor = Color.white;
|
||||||
// int arrayIx = 0;
|
// Handles.Label(labelPosition, receptor.instances.Count().ToString(), style);
|
||||||
// foreach (ReceptorInstance n in receptorI.receptorArray.receptors) {
|
|
||||||
// if (n == receptorI)
|
|
||||||
// break;
|
|
||||||
// arrayIx++;
|
|
||||||
// }
|
|
||||||
// Handles.Label(labelPosition, $"[{arrayIx}]", style);
|
|
||||||
// }
|
|
||||||
// }
|
// }
|
||||||
if (expandArray && nucleus is Receptor receptor2 && receptor2.array.nuclei.First() == this.currentNucleus) {
|
if (expandArray && nucleus is Receptor receptor2 && receptor2.array.nuclei.First() == this.currentNucleus) {
|
||||||
int arrayIx = 0;
|
style.alignment = TextAnchor.LowerCenter;
|
||||||
foreach (Nucleus n in receptor2.array.nuclei) {
|
Vector3 labelPos = position + Vector3.down * (size + 5); // below disc along up axis
|
||||||
if (n == nucleus)
|
int colonPos = nucleus.name.IndexOf(":");
|
||||||
break;
|
if (colonPos > 0) {
|
||||||
arrayIx++;
|
string extName = nucleus.name[(colonPos + 2)..];
|
||||||
|
Handles.Label(labelPos, extName, style);
|
||||||
}
|
}
|
||||||
Handles.Label(labelPosition, $"[{arrayIx}]", style);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
style.alignment = TextAnchor.UpperCenter;
|
style.alignment = TextAnchor.UpperCenter;
|
||||||
Vector3 labelPos = position - Vector3.down * (size + 10f); // below disc along up axis
|
Vector3 labelPos = position - Vector3.down * (size + 5); // below disc along up axis
|
||||||
int colonPos = nucleus.name.IndexOf(":");
|
int colonPos = nucleus.name.IndexOf(":");
|
||||||
if (colonPos > 0) {
|
if (colonPos > 0 && colonPos < nucleus.name.Length - 2) {
|
||||||
string baseName = nucleus.name[..colonPos];
|
string baseName = nucleus.name[..colonPos];
|
||||||
Handles.Label(labelPos, baseName, style);
|
Handles.Label(labelPos, baseName, style);
|
||||||
}
|
}
|
||||||
@ -602,7 +605,6 @@ public class ClusterInspector : Editor {
|
|||||||
this.currentNucleus.name = newName;
|
this.currentNucleus.name = newName;
|
||||||
this.prefab.RefreshOutputs();
|
this.prefab.RefreshOutputs();
|
||||||
outputsField.choices = this.prefab.outputs.Select(output => output.name).ToList();
|
outputsField.choices = this.prefab.outputs.Select(output => output.name).ToList();
|
||||||
//outputsField.value = newName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Application.isPlaying) {
|
if (Application.isPlaying) {
|
||||||
@ -729,22 +731,6 @@ public class ClusterInspector : Editor {
|
|||||||
if (receptor2.array == null || receptor2.array.nuclei == null || receptor2.array.nuclei.Count() == 0)
|
if (receptor2.array == null || receptor2.array.nuclei == null || receptor2.array.nuclei.Count() == 0)
|
||||||
receptor2.array = new NucleusArray(neuron);
|
receptor2.array = new NucleusArray(neuron);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (this.currentNucleus is Receptor receptor1) {
|
|
||||||
// EditorGUILayout.BeginHorizontal();
|
|
||||||
// EditorGUILayout.IntField("Array size", receptor1.array.nuclei.Count());
|
|
||||||
// if (GUILayout.Button("Add")) {
|
|
||||||
// Undo.RecordObject(prefabAsset, "Array add " + prefabAsset.name);
|
|
||||||
// receptor1.array.AddNucleus(this.prefab);
|
|
||||||
// anythingChanged = true;
|
|
||||||
// }
|
|
||||||
// if (GUILayout.Button("Del")) {
|
|
||||||
// Undo.RecordObject(prefabAsset, "Array delete " + prefabAsset.name);
|
|
||||||
// receptor1.array.RemoveNucleus();
|
|
||||||
// anythingChanged = true;
|
|
||||||
// }
|
|
||||||
// EditorGUILayout.EndHorizontal();
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorGUILayout.Space();
|
EditorGUILayout.Space();
|
||||||
@ -831,25 +817,7 @@ public class ClusterInspector : Editor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// protected virtual void AddInput(int selectedInputType, Nucleus nucleus) {
|
|
||||||
// switch (selectedInputType) {
|
|
||||||
// case 0: // Neuron
|
|
||||||
// AddNeuronInput(nucleus);
|
|
||||||
// break;
|
|
||||||
// case 1: // MemoryCell
|
|
||||||
// AddMemoryCellInput(nucleus);
|
|
||||||
// break;
|
|
||||||
// case 2: // Selector
|
|
||||||
// AddSelectorInput(nucleus);
|
|
||||||
// break;
|
|
||||||
// case 3: // Cluster
|
|
||||||
// AddClusterInput(nucleus);
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
protected virtual void AddNeuronInput(Nucleus nucleus) {
|
protected virtual void AddNeuronInput(Nucleus nucleus) {
|
||||||
//Neuron newNeuroid = new(this.cluster, "New neuron");
|
|
||||||
Neuron newNeuroid = new(this.prefab, "New neuron");
|
Neuron newNeuroid = new(this.prefab, "New neuron");
|
||||||
newNeuroid.AddReceiver(nucleus);
|
newNeuroid.AddReceiver(nucleus);
|
||||||
this.currentNucleus = newNeuroid;
|
this.currentNucleus = newNeuroid;
|
||||||
|
|||||||
@ -36,8 +36,10 @@ public class NucleusArray {
|
|||||||
|
|
||||||
for (int i = 0; i < this._nuclei.Length; i++)
|
for (int i = 0; i < this._nuclei.Length; i++)
|
||||||
newArray[i] = this._nuclei[i];
|
newArray[i] = this._nuclei[i];
|
||||||
if (this._nuclei[0] is Nucleus nucleus)
|
if (this._nuclei[0] is Nucleus nucleus) {
|
||||||
newArray[newLength - 1] = nucleus.Clone(prefab);
|
newArray[newLength - 1] = nucleus.Clone(prefab);
|
||||||
|
newArray[newLength - 1].name += $"{newLength - 1}";
|
||||||
|
}
|
||||||
|
|
||||||
this._nuclei = newArray;
|
this._nuclei = newArray;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user