Fixes
This commit is contained in:
parent
c1bf54a1cc
commit
f40d1ea4ae
@ -19,16 +19,15 @@ public class ClusterInspector : Editor {
|
||||
public override VisualElement CreateInspectorGUI() {
|
||||
ClusterPrefab prefab = target as ClusterPrefab;
|
||||
|
||||
string path = AssetDatabase.GetAssetPath(prefab); // or known path
|
||||
Debug.Log($"{path}");
|
||||
ClusterPrefab currentWrapper = AssetDatabase.LoadAssetAtPath<ClusterPrefab>(path);
|
||||
if (currentWrapper == null)
|
||||
Debug.LogError("CreateInspectorGUI: Cluster Prefab is not found on disk");
|
||||
// string path = AssetDatabase.GetAssetPath(prefab); // or known path
|
||||
// Debug.Log($"{path}");
|
||||
// ClusterPrefab currentWrapper = AssetDatabase.LoadAssetAtPath<ClusterPrefab>(path);
|
||||
// if (currentWrapper == null)
|
||||
// Debug.LogError("CreateInspectorGUI: Cluster Prefab is not found on disk");
|
||||
|
||||
if (prefab != null)
|
||||
prefab.EnsureInitialization();
|
||||
|
||||
|
||||
serializedObject.Update();
|
||||
|
||||
VisualElement root = new();
|
||||
@ -176,20 +175,13 @@ public class ClusterInspector : Editor {
|
||||
return;
|
||||
}
|
||||
|
||||
// if (currentWrapper != null)
|
||||
// DestroyImmediate(currentWrapper);
|
||||
// currentWrapper = CreateInstance<ClusterWrapper>().Init(this.currentNucleus, prefab);
|
||||
|
||||
string path = AssetDatabase.GetAssetPath(this.prefab); // or known path
|
||||
this.prefabAsset = AssetDatabase.LoadAssetAtPath<ClusterPrefab>(path);
|
||||
if (this.prefabAsset == null) {
|
||||
// create and save if it doesn't exist
|
||||
// create in memory save if it doesn't exist
|
||||
this.prefabAsset = CreateInstance<ClusterPrefab>();
|
||||
// AssetDatabase.CreateAsset(currentWrapper, "Assets/ClusterPrefab.asset");
|
||||
// AssetDatabase.SaveAssets();
|
||||
Debug.LogError("Cluster Prefab is not found on disk");
|
||||
}
|
||||
//currentWrapper.Init(this.currentNucleus, prefab);
|
||||
DrawInspector(inspectorContainer);
|
||||
}
|
||||
|
||||
@ -579,7 +571,7 @@ public class ClusterInspector : Editor {
|
||||
showSynapses = EditorGUILayout.BeginFoldoutHeaderGroup(showSynapses, "Synapses");
|
||||
if (showSynapses) {
|
||||
|
||||
ConnectNucleus(this.prefab, this.currentNucleus);
|
||||
anythingChanged = ConnectNucleus(this.prefab, this.currentNucleus);
|
||||
AddSynapse(this.prefab, this.currentNucleus);
|
||||
EditorGUILayout.Space();
|
||||
|
||||
@ -809,9 +801,9 @@ public class ClusterInspector : Editor {
|
||||
}
|
||||
|
||||
// Connect to another nucleus in the same cluster
|
||||
protected virtual void ConnectNucleus(ClusterPrefab cluster, Nucleus nucleus) {
|
||||
protected virtual bool ConnectNucleus(ClusterPrefab cluster, Nucleus nucleus) {
|
||||
if (cluster == null)
|
||||
return;
|
||||
return false;
|
||||
|
||||
IEnumerable<Nucleus> synapseNuclei = this.currentNucleus.synapses
|
||||
.Where(synapse => synapse.nucleus != null)
|
||||
@ -824,10 +816,12 @@ public class ClusterInspector : Editor {
|
||||
string[] names = nucleiNames.ToArray();
|
||||
int selectedIndex = -1;
|
||||
selectedIndex = EditorGUILayout.Popup("Connect", selectedIndex, names);
|
||||
if (selectedIndex >= 0) {
|
||||
if (selectedIndex < 0)
|
||||
return false;
|
||||
|
||||
Nucleus receptor = nuclei.ElementAt(selectedIndex);
|
||||
receptor.AddReceiver(this.currentNucleus);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected virtual void AddSynapse(ClusterPrefab cluster, Nucleus nucleus) {
|
||||
@ -865,29 +859,3 @@ public class NeuroidLayer {
|
||||
public int ix = 0;
|
||||
public List<Nucleus> neuroids = new();
|
||||
}
|
||||
|
||||
// public class ClusterWrapper : ScriptableObject {
|
||||
// // expose fields that map to GraphNode
|
||||
// //public string title;
|
||||
// public Vector2 position;
|
||||
// Nucleus node;
|
||||
// ClusterPrefab graph; // needed to write back and mark dirty
|
||||
|
||||
// public ClusterWrapper Init(Nucleus node, ClusterPrefab graphAsset) {
|
||||
// this.node = node;
|
||||
// this.graph = graphAsset;
|
||||
// //this.title = " A " + node.name;
|
||||
// //position = node.position;
|
||||
// return this;
|
||||
// }
|
||||
// void OnValidate() {
|
||||
// if (node != null) {
|
||||
// //node.name = title;
|
||||
// //node.position = position;
|
||||
// #if UNITY_EDITOR
|
||||
// if (graph != null)
|
||||
// UnityEditor.EditorUtility.SetDirty(graph);
|
||||
// #endif
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@ -17,11 +17,10 @@ public class Neuron : Nucleus {
|
||||
public Neuron(ClusterPrefab parent, string name) {
|
||||
this.cluster = parent;
|
||||
this.name = name;
|
||||
if (this.cluster != null) {
|
||||
if (this.cluster != null)
|
||||
this.cluster.nuclei.Add(this);
|
||||
}
|
||||
// else
|
||||
// Debug.LogError("No neuroid network");
|
||||
else
|
||||
Debug.LogError("No prefab when adding neuron to prefab");
|
||||
}
|
||||
|
||||
#region Serialization
|
||||
|
||||
@ -13,19 +13,19 @@ public class NucleusArray {
|
||||
return _nuclei;
|
||||
}
|
||||
}
|
||||
public string name;
|
||||
//public string name;
|
||||
|
||||
public NucleusArray(Nucleus nucleus) {
|
||||
this.name = nucleus.name;
|
||||
//this.name = nucleus.name;
|
||||
this._nuclei = new Nucleus[1];
|
||||
this._nuclei[0] = nucleus;
|
||||
}
|
||||
public NucleusArray(ClusterPrefab cluster) {
|
||||
this.name = cluster.name;
|
||||
//this.name = cluster.name;
|
||||
this._nuclei = new Nucleus[0];
|
||||
}
|
||||
public NucleusArray(int size, string name) {
|
||||
this.name = name;
|
||||
//this.name = name;
|
||||
this._nuclei = new Nucleus[size];
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user