All checks were successful
Copy Documentation to webserver / copy-documentation (push) Successful in 28s
42 lines
1.4 KiB
C#
42 lines
1.4 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;
|
|
|
|
/// <summary>
|
|
/// Retrieve a nucleus in this cluster
|
|
/// </summary>
|
|
/// <param name="nucleusName">The name of the nucleus</param>
|
|
/// <returns>The Nucleus with the given name or null if no such Nucleus could be found</returns>
|
|
public Nucleus GetNucleus(string nucleusName) {
|
|
return cluster.GetNucleus(nucleusName);
|
|
}
|
|
|
|
/// <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;
|
|
}
|
|
}
|
|
|
|
}
|