42 lines
1.2 KiB
C#
42 lines
1.2 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace NanoBrain.Unity {
|
|
|
|
/// <summary>
|
|
/// The Unity ScriptableObject to implement re-usable Cluster Prefabs
|
|
/// </summary>
|
|
[CreateAssetMenu(menuName = "Passer/Cluster")]
|
|
public class ClusterPrefab : ScriptableObject {
|
|
|
|
/// <summary>
|
|
/// The cluster data
|
|
/// </summary>
|
|
public Cluster cluster;
|
|
|
|
//[HideInInspector]
|
|
public int version;
|
|
|
|
/// <summary>
|
|
/// Call this function to ensure that there is at least one nucleus
|
|
/// </summary>
|
|
/// his is an invariant and should be ensured before the nucleus is used
|
|
/// because output requires it.
|
|
public void EnsureInitialization() {
|
|
this.cluster.prefab = this;
|
|
this.cluster.name = this.name;
|
|
this.cluster.nuclei ??= new List<Nucleus>();
|
|
if (this.cluster.nuclei.Count <= 0)
|
|
new Neuron(this.cluster, "Output"); // Every cluster should have at least 1 neuron
|
|
this.cluster.instanceCount = 1;
|
|
}
|
|
|
|
#if UNITY_EDITOR
|
|
private void OnValidate() {
|
|
version++;
|
|
}
|
|
#endif
|
|
}
|
|
|
|
}
|