Cleanup
This commit is contained in:
parent
5982c8acfe
commit
60e2b3e33f
@ -22,9 +22,6 @@ public class ClusterInspector : Editor {
|
|||||||
serializedObject.Update();
|
serializedObject.Update();
|
||||||
|
|
||||||
VisualElement root = new();
|
VisualElement root = new();
|
||||||
//root.style.flexDirection = FlexDirection.Row; // side-by-side layout
|
|
||||||
//root.style.flexGrow = 1;
|
|
||||||
//root.style.minHeight = 600;
|
|
||||||
root.style.paddingLeft = 0;
|
root.style.paddingLeft = 0;
|
||||||
root.style.paddingRight = 0;
|
root.style.paddingRight = 0;
|
||||||
root.style.paddingTop = 0;
|
root.style.paddingTop = 0;
|
||||||
@ -33,11 +30,8 @@ public class ClusterInspector : Editor {
|
|||||||
root.styleSheets.Add(Resources.Load<StyleSheet>("GraphStyles"));
|
root.styleSheets.Add(Resources.Load<StyleSheet>("GraphStyles"));
|
||||||
|
|
||||||
mainContainer = new() {
|
mainContainer = new() {
|
||||||
// name = "main",
|
|
||||||
style = {
|
style = {
|
||||||
// flexDirection = FlexDirection.Row,
|
height = 450
|
||||||
// flexGrow = 1,
|
|
||||||
height = 450,
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
GraphView graph = new();
|
GraphView graph = new();
|
||||||
@ -80,10 +74,6 @@ public class ClusterInspector : Editor {
|
|||||||
private readonly Dictionary<IReceptor, Vector2Int> neuroidPositions = new();
|
private readonly Dictionary<IReceptor, Vector2Int> neuroidPositions = new();
|
||||||
private bool expandArray = false;
|
private bool expandArray = false;
|
||||||
|
|
||||||
//Vector2 pan = Vector2.zero;
|
|
||||||
//float zoom = 1f;
|
|
||||||
//bool draggingCanvas = false;
|
|
||||||
//Vector2 lastMouse;
|
|
||||||
ClusterWrapper currentWrapper;
|
ClusterWrapper currentWrapper;
|
||||||
|
|
||||||
public GraphView() {
|
public GraphView() {
|
||||||
@ -98,11 +88,6 @@ public class ClusterInspector : Editor {
|
|||||||
imguiContainer.focusable = true;
|
imguiContainer.focusable = true;
|
||||||
Add(imguiContainer);
|
Add(imguiContainer);
|
||||||
|
|
||||||
//RegisterCallback<WheelEvent>(OnWheel);
|
|
||||||
// RegisterCallback<MouseDownEvent>(OnMouseDown);
|
|
||||||
// RegisterCallback<MouseMoveEvent>(OnMouseMove);
|
|
||||||
// RegisterCallback<MouseUpEvent>(OnMouseUp);
|
|
||||||
|
|
||||||
// Subscribe when added to panel (editor UI ready)
|
// Subscribe when added to panel (editor UI ready)
|
||||||
RegisterCallback<AttachToPanelEvent>(evt => Subscribe());
|
RegisterCallback<AttachToPanelEvent>(evt => Subscribe());
|
||||||
RegisterCallback<DetachFromPanelEvent>(evt => Unsubscribe());
|
RegisterCallback<DetachFromPanelEvent>(evt => Unsubscribe());
|
||||||
@ -249,9 +234,7 @@ public class ClusterInspector : Editor {
|
|||||||
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);
|
// The selected nucleus highlight ring
|
||||||
|
|
||||||
Handles.color = Color.white;
|
|
||||||
Handles.DrawSolidDisc(pos, Vector3.forward, size + 2);
|
Handles.DrawSolidDisc(pos, Vector3.forward, size + 2);
|
||||||
DrawNucleus(nucleus, pos, maxValue, size);
|
DrawNucleus(nucleus, pos, maxValue, size);
|
||||||
row++;
|
row++;
|
||||||
@ -266,6 +249,7 @@ public class ClusterInspector : Editor {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Handles.color = Color.white;
|
Handles.color = Color.white;
|
||||||
|
// The selected nucleus highlight ring
|
||||||
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);
|
||||||
}
|
}
|
||||||
@ -726,17 +710,17 @@ public class ClusterInspector : Editor {
|
|||||||
#region Update
|
#region Update
|
||||||
|
|
||||||
private void UpdateLayout(float containerWidth) {
|
private void UpdateLayout(float containerWidth) {
|
||||||
if (containerWidth > 600f) {
|
// if (containerWidth > 600f) {
|
||||||
mainContainer.style.flexDirection = FlexDirection.Row;
|
mainContainer.style.flexDirection = FlexDirection.Row;
|
||||||
inspectorContainer.style.width = 300; // fixed sidebar width
|
inspectorContainer.style.width = 300; // fixed sidebar width
|
||||||
inspectorContainer.style.flexGrow = 0;
|
inspectorContainer.style.flexGrow = 0;
|
||||||
}
|
// }
|
||||||
else {
|
// else {
|
||||||
mainContainer.style.flexDirection = FlexDirection.Column;
|
// mainContainer.style.flexDirection = FlexDirection.Column;
|
||||||
inspectorContainer.style.width = Length.Percent(100); // full width below
|
// inspectorContainer.style.width = Length.Percent(100); // full width below
|
||||||
inspectorContainer.style.flexDirection = FlexDirection.Column;
|
// inspectorContainer.style.flexDirection = FlexDirection.Column;
|
||||||
inspectorContainer.style.flexGrow = 1; // can set 0 or keep as needed
|
// inspectorContainer.style.flexGrow = 1; // can set 0 or keep as needed
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Update
|
#endregion Update
|
||||||
|
|||||||
@ -22,7 +22,6 @@ public class NanoBrainComponent_Editor : Editor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override VisualElement CreateInspectorGUI() {
|
public override VisualElement CreateInspectorGUI() {
|
||||||
//ClusterPrefab brain = Application.isPlaying ? component.brain.prefab : component.defaultBrain;
|
|
||||||
Cluster brain = component.brain;
|
Cluster brain = component.brain;
|
||||||
|
|
||||||
if (Application.isPlaying == false)
|
if (Application.isPlaying == false)
|
||||||
@ -93,37 +92,37 @@ public class NanoBrainComponent_Editor : Editor {
|
|||||||
// board.OnIMGUI();
|
// board.OnIMGUI();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
void OnSceneGui(SceneView sv) {
|
// void OnSceneGui(SceneView sv) {
|
||||||
if (Application.isPlaying == false)
|
// if (Application.isPlaying == false)
|
||||||
return;
|
// return;
|
||||||
// May need some throttling here...
|
// // May need some throttling here...
|
||||||
if (board != null) {
|
// if (board != null) {
|
||||||
Debug.Log(".");
|
// Debug.Log(".");
|
||||||
board.OnIMGUI();
|
// board.OnIMGUI();
|
||||||
}
|
// }
|
||||||
|
|
||||||
// EditorApplication.delayCall = UpdateInspectorUI;
|
// // EditorApplication.delayCall = UpdateInspectorUI;
|
||||||
}
|
// }
|
||||||
|
|
||||||
void UpdateInspectorUI() {
|
// void UpdateInspectorUI() {
|
||||||
if (board != null) {
|
// if (board != null) {
|
||||||
Debug.Log(".");
|
// Debug.Log(".");
|
||||||
board.OnIMGUI();
|
// board.OnIMGUI();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
private void UpdateLayout(float containerWidth) {
|
private void UpdateLayout(float containerWidth) {
|
||||||
if (containerWidth > 800f) {
|
// if (containerWidth > 800f) {
|
||||||
mainContainer.style.flexDirection = FlexDirection.Row;
|
mainContainer.style.flexDirection = FlexDirection.Row;
|
||||||
inspectorContainer.style.width = 400; // fixed sidebar width
|
inspectorContainer.style.width = 400; // fixed sidebar width
|
||||||
inspectorContainer.style.flexGrow = 0;
|
inspectorContainer.style.flexGrow = 0;
|
||||||
}
|
// }
|
||||||
else {
|
// else {
|
||||||
mainContainer.style.flexDirection = FlexDirection.Column;
|
// mainContainer.style.flexDirection = FlexDirection.Column;
|
||||||
inspectorContainer.style.width = Length.Percent(100); // full width below
|
// inspectorContainer.style.width = Length.Percent(100); // full width below
|
||||||
inspectorContainer.style.flexDirection = FlexDirection.Column;
|
// inspectorContainer.style.flexDirection = FlexDirection.Column;
|
||||||
inspectorContainer.style.flexGrow = 1; // can set 0 or keep as needed
|
// inspectorContainer.style.flexGrow = 1; // can set 0 or keep as needed
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
78
Receptor.cs
78
Receptor.cs
@ -27,47 +27,60 @@ public class Receptor : IReceptor {
|
|||||||
cluster.nuclei.Add(this);
|
cluster.nuclei.Add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Receptor(ClusterPrefab cluster, INucleus nucleus) {
|
// public Receptor(ClusterPrefab cluster, INucleus nucleus) {
|
||||||
this.cluster = cluster;
|
// this.cluster = cluster;
|
||||||
if (cluster != null)
|
// if (cluster != null)
|
||||||
cluster.nuclei.Add(this);
|
// cluster.nuclei.Add(this);
|
||||||
|
// this.AddReceiver(nucleus);
|
||||||
|
// }
|
||||||
|
public Receptor(Cluster parent, string name, string nucleusName) {
|
||||||
|
this.parent = parent ?? throw new ArgumentNullException(nameof(parent), "Parent cannot be null.");
|
||||||
|
|
||||||
|
this.name = name;
|
||||||
|
this.parent.nuclei.Add(this);
|
||||||
|
foreach (INucleus nucleus in parent.inputs) {
|
||||||
|
if (nucleus != null && nucleus.name == nucleusName) {
|
||||||
this.AddReceiver(nucleus);
|
this.AddReceiver(nucleus);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Obsolete("This method is deprecated. Use Receptor() constructor instead.")]
|
||||||
public static Receptor CreateReceptor(Cluster cluster, string nucleusName) {
|
public static Receptor CreateReceptor(Cluster cluster, string nucleusName) {
|
||||||
if (cluster == null)
|
return new Receptor(cluster, "Receptor", nucleusName);
|
||||||
return null;
|
// if (cluster == null)
|
||||||
|
// return null;
|
||||||
|
|
||||||
Receptor receptor = new(cluster);
|
// Receptor receptor = new(cluster);
|
||||||
foreach (INucleus nucleus in cluster.inputs) {
|
// foreach (INucleus nucleus in cluster.inputs) {
|
||||||
if (nucleus != null && nucleus.name == nucleusName) {
|
// if (nucleus != null && nucleus.name == nucleusName) {
|
||||||
receptor.AddReceiver(nucleus);
|
// receptor.AddReceiver(nucleus);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if (receptor._receivers.Count == 0)
|
// if (receptor._receivers.Count == 0)
|
||||||
return null;
|
// return null;
|
||||||
else
|
// else
|
||||||
return receptor;
|
// return receptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual IReceptor ShallowCloneTo(Cluster parent) {
|
public virtual IReceptor ShallowCloneTo(Cluster parent) {
|
||||||
Receptor clone = new(parent);
|
Receptor clone = new(parent);
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
public virtual IReceptor ShallowCloneTo(ClusterPrefab parent) {
|
// public virtual IReceptor ShallowCloneTo(ClusterPrefab parent) {
|
||||||
Receptor clone = new(parent);
|
// Receptor clone = new(parent);
|
||||||
return clone;
|
// return clone;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public virtual IReceptor CloneTo(ClusterPrefab parent) {
|
// public virtual IReceptor CloneTo(ClusterPrefab parent) {
|
||||||
Receptor clone = new(parent);
|
// Receptor clone = new(parent);
|
||||||
|
|
||||||
foreach (INucleus receiver in this.receivers) {
|
// foreach (INucleus receiver in this.receivers) {
|
||||||
clone.AddReceiver(receiver);
|
// clone.AddReceiver(receiver);
|
||||||
}
|
// }
|
||||||
|
|
||||||
return clone;
|
// return clone;
|
||||||
}
|
// }
|
||||||
public virtual IReceptor Clone() {
|
public virtual IReceptor Clone() {
|
||||||
Receptor clone = new(this.cluster);
|
Receptor clone = new(this.cluster);
|
||||||
|
|
||||||
@ -175,10 +188,15 @@ public class Receptor : IReceptor {
|
|||||||
}
|
}
|
||||||
receiverIx++;
|
receiverIx++;
|
||||||
}
|
}
|
||||||
// Debug.Log($"Receiver {selectedReceiver.name}[{selectedReceiverIx}] for thing {thingId}");
|
Debug.Log($"Receiver {selectedReceiver.name}[{selectedReceiverIx}] for thing {thingId}");
|
||||||
thingIds[selectedReceiverIx] = thingId;
|
thingIds[selectedReceiverIx] = thingId;
|
||||||
// if (thingName != null)
|
if (thingName != null) {
|
||||||
// selectedReceiver.nucleus.name = selectedReceiver.nucleus.baseName + " " + thingName;
|
string baseName = selectedReceiver.name;
|
||||||
|
int colonPos = selectedReceiver.name.IndexOf(":");
|
||||||
|
if (colonPos > 0)
|
||||||
|
baseName = selectedReceiver.name.Substring(0, colonPos);
|
||||||
|
selectedReceiver.name = baseName + ": " + thingName;
|
||||||
|
}
|
||||||
selectedReceiver.parent.UpdateStateIsolated();
|
selectedReceiver.parent.UpdateStateIsolated();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user