Skip to main content

SpawnPositions

A class in Root.Township, the global namespace.

Fixed list of spawn points for a population, either live child transforms or positions and rotations cached relative to this object.

Constructors​

MemberWhat it is
SpawnPositions()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

5 private and internal fields
MemberWhat it is
private bool btnCacheInspector button that calls Cache.
private static Logger loggerNLog logger for this class.
private Vector3[] positionsCached local positions, used when no transforms are set.
private Quaternion[] rotationsCached local rotations matching positions.
private Transform[] transformsSpawn point transforms; when not empty they win over the cached arrays.

Properties​

MemberWhat it is
int Count { get; }Number of spawn points: the transforms if any are set, else the cached positions.

Methods​

MemberWhat it is
void Cache()Editor: copies the transforms' local positions and rotations into the arrays, then clears the transform list.
SpawnPoint GetLocalSpawnPosition(int index)Returns spawn point index in local space; logs an error and returns null if the index is bad.
SpawnPoint GetSpawnPosition(int index)Returns spawn point index in world space; logs an error and returns null if the index is bad.
2 private and internal methods
MemberWhat it is
private void OnValidate()Editor: runs the cache button and keeps the rotations array the same length as the positions.
private void ISpawnPositions.SetSize(float size)Part of ISpawnPositions; does nothing here.

Used in​

Members of other types that take, return or hold a SpawnPositions: