Skip to main content

TestSpawner

A class in Root.Township, the global namespace.

Developer test behaviour that, on the server, spawns a prefab many times in a grid or scattered pattern into this entity's chunk.

Constructors​

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

Fields​

6 private and internal fields
MemberWhat it is
private int gridSizeNumber of rows and columns for grid mode.
private float gridSpacingDistance between grid points.
private TestSpawner.Mode modeWhich spawn pattern to use.
private NetworkPrefab prefabPrefab to spawn.
private float radiusSize of the area for rect mode.
private int scatterCountNumber of spawns for the scatter modes.

Methods​

MemberWhat it is
override void InitializeAsServer(SpawnData spawnData)Server: spawns the prefab in the chosen pattern.
8 private and internal methods
MemberWhat it is
private void Gizmo(Vector3 position)Draws a small cube at a spawn position.
private void Grid(Action<Vector3> spawn)Calls the spawn action on a gridSize by gridSize grid centred here.
private void Handle(Action<Vector3> spawn)Runs the pattern chosen by mode with the given action.
private void OnDrawGizmosSelected()Previews the spawn pattern with yellow cubes. Random modes show new points every redraw.
private void ScatterEvenCircle(Action<Vector3> spawn)Random points in a circle of radius 1 around this object; radius isn't used.
private void ScatterRect(Action<Vector3> spawn)Random points in a square radius wide centred here.
private void ScatterWeightedCircle(Action<Vector3> spawn)Random points from a unit sphere flattened onto the ground, so more fall near the centre.
private void Spawn(Vector3 position)Spawns the prefab at a position in this entity's chunk.