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