Inspector cleanup
This commit is contained in:
parent
7bcd4a6cf1
commit
e8471683d6
@ -498,7 +498,8 @@ public class ClusterInspector : Editor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int selectedInputType = 0;
|
//private int selectedInputType = 0;
|
||||||
|
private bool showSynapses = true;
|
||||||
void DrawInspector(VisualElement inspectorContainer) {
|
void DrawInspector(VisualElement inspectorContainer) {
|
||||||
if (inspectorContainer == null)
|
if (inspectorContainer == null)
|
||||||
return;
|
return;
|
||||||
@ -517,19 +518,15 @@ public class ClusterInspector : Editor {
|
|||||||
if (this.currentNucleus == null)
|
if (this.currentNucleus == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GUIStyle headerStyle = new GUIStyle(EditorStyles.boldLabel) {
|
GUIStyle headerStyle = new(EditorStyles.boldLabel) {
|
||||||
alignment = TextAnchor.MiddleLeft,
|
alignment = TextAnchor.MiddleLeft,
|
||||||
margin = new RectOffset(10, 0, 4, 4)
|
margin = new RectOffset(10, 0, 4, 4)
|
||||||
};
|
};
|
||||||
//GUI.backgroundColor = EditorGUIUtility.isProSkin ? new Color(0.15f, 0.15f, 0.15f) : new Color(0.85f, 0.85f, 0.85f);
|
GUIStyle boldTextFieldStyle = new(EditorStyles.textField) {
|
||||||
//GUILayout.BeginVertical("box");
|
|
||||||
GUIStyle boldTextFieldStyle = new GUIStyle(EditorStyles.textField) {
|
|
||||||
fontStyle = FontStyle.Bold
|
fontStyle = FontStyle.Bold
|
||||||
};
|
};
|
||||||
|
|
||||||
GUILayout.Label(this.currentNucleus.GetType().ToString(), headerStyle);
|
GUILayout.Label(this.currentNucleus.GetType().ToString(), headerStyle);
|
||||||
//GUILayout.EndVertical();
|
|
||||||
//GUI.backgroundColor = Color.white; // Reset background color
|
|
||||||
this.currentNucleus.name = EditorGUILayout.TextField(this.currentNucleus.name, boldTextFieldStyle);
|
this.currentNucleus.name = EditorGUILayout.TextField(this.currentNucleus.name, boldTextFieldStyle);
|
||||||
if (this.currentNucleus is Neuron neuroid) {
|
if (this.currentNucleus is Neuron neuroid) {
|
||||||
if (this.currentNucleus is MemoryCell memory) {
|
if (this.currentNucleus is MemoryCell memory) {
|
||||||
@ -561,8 +558,12 @@ public class ClusterInspector : Editor {
|
|||||||
else
|
else
|
||||||
EditorGUILayout.LabelField(" ");
|
EditorGUILayout.LabelField(" ");
|
||||||
|
|
||||||
|
showSynapses = EditorGUILayout.BeginFoldoutHeaderGroup(showSynapses, "Synapses");
|
||||||
|
if (showSynapses) {
|
||||||
|
ConnectNucleus(this.cluster, this.currentNucleus);
|
||||||
|
AddSynapse(this.cluster, this.currentNucleus);
|
||||||
|
|
||||||
if (this.currentNucleus.synapses.Count > 0) {
|
if (this.currentNucleus.synapses.Count > 0) {
|
||||||
EditorGUILayout.LabelField("Synapses");
|
|
||||||
Synapse[] synapses = this.currentNucleus.synapses.ToArray();
|
Synapse[] synapses = this.currentNucleus.synapses.ToArray();
|
||||||
foreach (Synapse synapse in synapses) {
|
foreach (Synapse synapse in synapses) {
|
||||||
if (synapse.nucleus != null) {
|
if (synapse.nucleus != null) {
|
||||||
@ -582,28 +583,11 @@ public class ClusterInspector : Editor {
|
|||||||
EditorGUI.indentLevel++;
|
EditorGUI.indentLevel++;
|
||||||
synapse.weight = EditorGUILayout.FloatField("Weight", synapse.weight);
|
synapse.weight = EditorGUILayout.FloatField("Weight", synapse.weight);
|
||||||
EditorGUI.indentLevel--;
|
EditorGUI.indentLevel--;
|
||||||
//EditorGUI.EndDisabledGroup();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
EditorGUILayout.Space();
|
EditorGUILayout.EndFoldoutHeaderGroup();
|
||||||
|
|
||||||
ConnectNucleus(this.cluster, this.currentNucleus);
|
|
||||||
|
|
||||||
EditorGUILayout.BeginHorizontal();
|
|
||||||
string[] options = { "Neuron", "MemoryCell", "Selector", "Cluster" };
|
|
||||||
selectedInputType = EditorGUILayout.Popup(selectedInputType, options);
|
|
||||||
if (GUILayout.Button("Add Input"))
|
|
||||||
AddInput(selectedInputType, this.currentNucleus);
|
|
||||||
EditorGUILayout.EndHorizontal();
|
|
||||||
|
|
||||||
// if (GUILayout.Button("Add Input Neuron"))
|
|
||||||
// AddInputNeuron(this.currentNucleus);
|
|
||||||
// if (GUILayout.Button("Add Input MemoryCell"))
|
|
||||||
// AddInputMemoryCell(this.currentNucleus);
|
|
||||||
// if (GUILayout.Button("Add Input Cluster"))
|
|
||||||
// AddCluster(this.currentNucleus);
|
|
||||||
|
|
||||||
EditorGUILayout.Space();
|
EditorGUILayout.Space();
|
||||||
|
|
||||||
@ -722,13 +706,24 @@ public class ClusterInspector : Editor {
|
|||||||
|
|
||||||
string[] names = nucleiNames.ToArray();
|
string[] names = nucleiNames.ToArray();
|
||||||
int selectedIndex = -1;
|
int selectedIndex = -1;
|
||||||
selectedIndex = EditorGUILayout.Popup("Connect to", selectedIndex, names);
|
selectedIndex = EditorGUILayout.Popup("Connect", selectedIndex, names);
|
||||||
if (selectedIndex >= 0) {
|
if (selectedIndex >= 0) {
|
||||||
Nucleus receptor = nuclei.ElementAt(selectedIndex);
|
Nucleus receptor = nuclei.ElementAt(selectedIndex);
|
||||||
receptor.AddReceiver(this.currentNucleus);
|
receptor.AddReceiver(this.currentNucleus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual void AddSynapse(ClusterPrefab cluster, Nucleus nucleus) {
|
||||||
|
if (cluster == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
string[] options = { "Neuron", "MemoryCell", "Selector", "Cluster" };
|
||||||
|
int selectedInputType = -1;
|
||||||
|
selectedInputType = EditorGUILayout.Popup("Add", selectedInputType, options);
|
||||||
|
if (selectedInputType >= 0)
|
||||||
|
AddInput(selectedInputType, this.currentNucleus);
|
||||||
|
}
|
||||||
|
|
||||||
protected virtual void DisconnectNucleus(Neuron nucleus) {
|
protected virtual void DisconnectNucleus(Neuron nucleus) {
|
||||||
if (this.currentNucleus.cluster == null)
|
if (this.currentNucleus.cluster == null)
|
||||||
return;
|
return;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user