gaze with clusterreceptor
This commit is contained in:
parent
cbc8296e55
commit
9c730709f1
@ -8,6 +8,15 @@ using static Unity.Mathematics.math;
|
|||||||
[Serializable]
|
[Serializable]
|
||||||
public class Cluster : Nucleus {
|
public class Cluster : Nucleus {
|
||||||
|
|
||||||
|
public string baseName {
|
||||||
|
get {
|
||||||
|
int colonPositon = this.name.IndexOf(':');
|
||||||
|
if (colonPositon < 0)
|
||||||
|
return this.name;
|
||||||
|
return this.name[..colonPositon];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#region Init
|
#region Init
|
||||||
|
|
||||||
public Cluster(ClusterPrefab prefab, Cluster parent) {
|
public Cluster(ClusterPrefab prefab, Cluster parent) {
|
||||||
|
|||||||
@ -488,7 +488,7 @@ public class ClusterInspector : Editor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (expandArray == false) {
|
if (expandArray == false || nucleus is not IReceptor) {
|
||||||
// put name below nucleus
|
// put name below nucleus
|
||||||
Vector3 labelPos = position - Vector3.down * (size + 5); // below neuron
|
Vector3 labelPos = position - Vector3.down * (size + 5); // below neuron
|
||||||
style.alignment = TextAnchor.UpperCenter;
|
style.alignment = TextAnchor.UpperCenter;
|
||||||
@ -624,34 +624,16 @@ public class ClusterInspector : Editor {
|
|||||||
EditorGUILayout.IntField("Array size", receptor1.nucleiArray.Count());
|
EditorGUILayout.IntField("Array size", receptor1.nucleiArray.Count());
|
||||||
if (GUILayout.Button("Add")) {
|
if (GUILayout.Button("Add")) {
|
||||||
Undo.RecordObject(prefabAsset, "Array add " + prefabAsset.name);
|
Undo.RecordObject(prefabAsset, "Array add " + prefabAsset.name);
|
||||||
//receptor1.array.AddNucleus(this.prefab);
|
|
||||||
receptor1.AddReceptorElement(this.prefab);
|
receptor1.AddReceptorElement(this.prefab);
|
||||||
anythingChanged = true;
|
anythingChanged = true;
|
||||||
}
|
}
|
||||||
if (GUILayout.Button("Del")) {
|
if (GUILayout.Button("Del")) {
|
||||||
Undo.RecordObject(prefabAsset, "Array delete " + prefabAsset.name);
|
Undo.RecordObject(prefabAsset, "Array delete " + prefabAsset.name);
|
||||||
//receptor1.array.RemoveNucleus();
|
|
||||||
receptor1.RemoveReceptorElement();
|
receptor1.RemoveReceptorElement();
|
||||||
anythingChanged = true;
|
anythingChanged = true;
|
||||||
}
|
}
|
||||||
EditorGUILayout.EndHorizontal();
|
EditorGUILayout.EndHorizontal();
|
||||||
}
|
}
|
||||||
// else if (this.currentNucleus is ClusterReceptor receptor2) {
|
|
||||||
// EditorGUILayout.BeginHorizontal();
|
|
||||||
// EditorGUILayout.IntField("Array size", receptor2.array.nuclei.Count());
|
|
||||||
// if (GUILayout.Button("Add")) {
|
|
||||||
// Undo.RecordObject(prefabAsset, "Array add " + prefabAsset.name);
|
|
||||||
// receptor2.array.AddNucleus(this.prefab);
|
|
||||||
// anythingChanged = true;
|
|
||||||
// }
|
|
||||||
// if (GUILayout.Button("Del")) {
|
|
||||||
// Undo.RecordObject(prefabAsset, "Array delete " + prefabAsset.name);
|
|
||||||
// receptor2.array.RemoveNucleus();
|
|
||||||
// anythingChanged = true;
|
|
||||||
// }
|
|
||||||
// EditorGUILayout.EndHorizontal();
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
// Synapses
|
// Synapses
|
||||||
|
|
||||||
@ -666,7 +648,7 @@ public class ClusterInspector : Editor {
|
|||||||
|
|
||||||
EditorGUIUtility.wideMode = true;
|
EditorGUIUtility.wideMode = true;
|
||||||
EditorGUIUtility.labelWidth = 100;
|
EditorGUIUtility.labelWidth = 100;
|
||||||
Vector3 newBias = EditorGUILayout.Vector3Field("Bias", this.currentNucleus.bias); //, GUILayout.Width(200));
|
Vector3 newBias = EditorGUILayout.Vector3Field("Bias", this.currentNucleus.bias);
|
||||||
anythingChanged |= newBias != this.currentNucleus.bias;
|
anythingChanged |= newBias != this.currentNucleus.bias;
|
||||||
this.currentNucleus.bias = newBias;
|
this.currentNucleus.bias = newBias;
|
||||||
|
|
||||||
@ -705,8 +687,8 @@ public class ClusterInspector : Editor {
|
|||||||
GUIStyle labelStyle = new(GUI.skin.label);
|
GUIStyle labelStyle = new(GUI.skin.label);
|
||||||
float labelWidth = 200;
|
float labelWidth = 200;
|
||||||
if (synapse.nucleus.clusterPrefab != null) {
|
if (synapse.nucleus.clusterPrefab != null) {
|
||||||
labelWidth = labelStyle.CalcSize(new GUIContent($"{synapse.nucleus.clusterPrefab.name}.")).x;
|
labelWidth = labelStyle.CalcSize(new GUIContent($"{synapse.nucleus.parent.baseName}.")).x;
|
||||||
GUILayout.Label($"{synapse.nucleus.clusterPrefab.name}", GUILayout.Width(labelWidth));
|
GUILayout.Label($"{synapse.nucleus.parent.baseName}", GUILayout.Width(labelWidth));
|
||||||
}
|
}
|
||||||
string[] options = synapse.nucleus.parent.clusterNuclei.Select(n => n.name).ToArray();
|
string[] options = synapse.nucleus.parent.clusterNuclei.Select(n => n.name).ToArray();
|
||||||
int selectedIndex = System.Array.IndexOf(options, synapse.nucleus.name);
|
int selectedIndex = System.Array.IndexOf(options, synapse.nucleus.name);
|
||||||
@ -753,32 +735,33 @@ public class ClusterInspector : Editor {
|
|||||||
|
|
||||||
// Activation
|
// Activation
|
||||||
|
|
||||||
EditorGUILayout.Space();
|
if (this.currentNucleus is not Cluster) {
|
||||||
showActivation = EditorGUILayout.BeginFoldoutHeaderGroup(showActivation, "Activation");
|
|
||||||
if (showActivation) {
|
|
||||||
if (this.currentNucleus is Neuron neuron) {
|
|
||||||
if (this.currentNucleus is not MemoryCell) {
|
|
||||||
EditorGUILayout.BeginHorizontal();
|
|
||||||
EditorGUILayout.LabelField("Activation Curve", GUILayout.Width(150));
|
|
||||||
if (neuron.curveMax > 0)
|
|
||||||
EditorGUILayout.CurveField(neuron.curve, Color.cyan, new Rect(0, 0, 1, neuron.curveMax));
|
|
||||||
else
|
|
||||||
EditorGUILayout.CurveField(neuron.curve, Color.cyan, new Rect(0, neuron.curveMax, 1, -neuron.curveMax));
|
|
||||||
Neuron.CurvePresets newPreset = (Neuron.CurvePresets)EditorGUILayout.EnumPopup(neuron.curvePreset, GUILayout.Width(100));
|
|
||||||
anythingChanged |= newPreset != neuron.curvePreset;
|
|
||||||
neuron.curvePreset = newPreset;
|
|
||||||
EditorGUILayout.EndHorizontal();
|
|
||||||
}
|
|
||||||
if (neuron is Receptor receptor2) {
|
|
||||||
if (receptor2.nucleiArray == null || receptor2.nucleiArray.Count() == 0)
|
|
||||||
receptor2.array = new NucleusArray(neuron);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
EditorGUILayout.Space();
|
EditorGUILayout.Space();
|
||||||
}
|
showActivation = EditorGUILayout.BeginFoldoutHeaderGroup(showActivation, "Activation");
|
||||||
EditorGUILayout.EndFoldoutHeaderGroup();
|
if (showActivation) {
|
||||||
|
if (this.currentNucleus is Neuron neuron) {
|
||||||
|
if (this.currentNucleus is not MemoryCell) {
|
||||||
|
EditorGUILayout.BeginHorizontal();
|
||||||
|
EditorGUILayout.LabelField("Activation Curve", GUILayout.Width(150));
|
||||||
|
if (neuron.curveMax > 0)
|
||||||
|
EditorGUILayout.CurveField(neuron.curve, Color.cyan, new Rect(0, 0, 1, neuron.curveMax));
|
||||||
|
else
|
||||||
|
EditorGUILayout.CurveField(neuron.curve, Color.cyan, new Rect(0, neuron.curveMax, 1, -neuron.curveMax));
|
||||||
|
Neuron.CurvePresets newPreset = (Neuron.CurvePresets)EditorGUILayout.EnumPopup(neuron.curvePreset, GUILayout.Width(100));
|
||||||
|
anythingChanged |= newPreset != neuron.curvePreset;
|
||||||
|
neuron.curvePreset = newPreset;
|
||||||
|
EditorGUILayout.EndHorizontal();
|
||||||
|
}
|
||||||
|
if (neuron is Receptor receptor2) {
|
||||||
|
if (receptor2.nucleiArray == null || receptor2.nucleiArray.Count() == 0)
|
||||||
|
receptor2.array = new NucleusArray(neuron);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EditorGUILayout.Space();
|
||||||
|
}
|
||||||
|
EditorGUILayout.EndFoldoutHeaderGroup();
|
||||||
|
}
|
||||||
|
|
||||||
if (GUILayout.Button("Delete this neuron"))
|
if (GUILayout.Button("Delete this neuron"))
|
||||||
DeleteNucleus(this.currentNucleus);
|
DeleteNucleus(this.currentNucleus);
|
||||||
|
|||||||
@ -13,18 +13,31 @@ MonoBehaviour:
|
|||||||
m_Name: Velocity
|
m_Name: Velocity
|
||||||
m_EditorClassIdentifier: Assembly-CSharp::ClusterPrefab
|
m_EditorClassIdentifier: Assembly-CSharp::ClusterPrefab
|
||||||
nuclei:
|
nuclei:
|
||||||
- rid: 2243601425629446539
|
- rid: 2262690551513219315
|
||||||
|
- rid: 2262690551513219316
|
||||||
|
- rid: 2262690551513219317
|
||||||
references:
|
references:
|
||||||
version: 2
|
version: 2
|
||||||
RefIds:
|
RefIds:
|
||||||
- rid: 2243601425629446539
|
- rid: -2
|
||||||
|
type: {class: , ns: , asm: }
|
||||||
|
- rid: 2262690551513219315
|
||||||
type: {class: Neuron, ns: , asm: Assembly-CSharp}
|
type: {class: Neuron, ns: , asm: Assembly-CSharp}
|
||||||
data:
|
data:
|
||||||
_name: Output
|
name: Velocity
|
||||||
_synapses: []
|
clusterPrefab: {fileID: 11400000}
|
||||||
_receivers: []
|
parent:
|
||||||
_array:
|
rid: -2
|
||||||
rid: 2243601425629446540
|
trace: 0
|
||||||
|
bias: {x: 0, y: 0, z: 0}
|
||||||
|
_synapses:
|
||||||
|
- nucleus:
|
||||||
|
rid: 2262690551513219316
|
||||||
|
weight: 1
|
||||||
|
- nucleus:
|
||||||
|
rid: 2262690551513219317
|
||||||
|
weight: 1
|
||||||
|
combinator: 0
|
||||||
_curvePreset: 0
|
_curvePreset: 0
|
||||||
curve:
|
curve:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@ -51,10 +64,65 @@ MonoBehaviour:
|
|||||||
m_PostInfinity: 2
|
m_PostInfinity: 2
|
||||||
m_RotationOrder: 4
|
m_RotationOrder: 4
|
||||||
curveMax: 1
|
curveMax: 1
|
||||||
average: 0
|
_receivers: []
|
||||||
- rid: 2243601425629446540
|
- rid: 2262690551513219316
|
||||||
type: {class: NucleusArray, ns: , asm: Assembly-CSharp}
|
type: {class: Neuron, ns: , asm: Assembly-CSharp}
|
||||||
data:
|
data:
|
||||||
_nuclei:
|
name: Position
|
||||||
- rid: 2243601425629446539
|
clusterPrefab: {fileID: 11400000}
|
||||||
name: Output
|
parent:
|
||||||
|
rid: -2
|
||||||
|
trace: 0
|
||||||
|
bias: {x: 0, y: 0, z: 0}
|
||||||
|
_synapses: []
|
||||||
|
combinator: 0
|
||||||
|
_curvePreset: 0
|
||||||
|
curve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 1
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0
|
||||||
|
outWeight: 0
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 1000
|
||||||
|
value: 1000
|
||||||
|
inSlope: 1
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0
|
||||||
|
outWeight: 0
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
curveMax: 1
|
||||||
|
_receivers:
|
||||||
|
- rid: 2262690551513219315
|
||||||
|
- rid: 2262690551513219317
|
||||||
|
type: {class: MemoryCell, ns: , asm: Assembly-CSharp}
|
||||||
|
data:
|
||||||
|
name: New memory cell
|
||||||
|
clusterPrefab: {fileID: 11400000}
|
||||||
|
parent:
|
||||||
|
rid: -2
|
||||||
|
trace: 0
|
||||||
|
bias: {x: 0, y: 0, z: 0}
|
||||||
|
_synapses: []
|
||||||
|
combinator: 0
|
||||||
|
_curvePreset: 0
|
||||||
|
curve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve: []
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
curveMax: 1
|
||||||
|
_receivers:
|
||||||
|
- rid: 2262690551513219315
|
||||||
|
staticMemory: 0
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user