Skip to main content

ClumpSpawner

A class in Root.Township, Alta.Environmental.Vegetation.

Scatters grass clump prefabs in a circle or square around itself at start and groups them in a LOD group. Mostly a tool for building scenes.

Constructors​

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

Fields​

8 private and internal fields
MemberWhat it is
private Material grassMaterialSerialized grass material. Not read in this file.
private bool isToRefreshTick to clear and respawn the clumps.
private LODGroup lodGroupLOD group added at start.
private ClumpSpawner.ClumpLOD[] lodStepsPrefab, LOD threshold and spawn chance for each LOD level.
private int loopInstanceControlerYields a frame after this many clumps. Default 100.
private int numberOfClumpsHow many clumps to spawn.
private ClumpSpawner.Shape shapeSpawn area shape, circle or square.
private float widthRadius or half width of the spawn area.

Properties​

1 private and internal property
MemberWhat it is
private bool HasPrefabs { get; }True if any LOD steps are set.

Methods​

5 private and internal methods
MemberWhat it is
private void OnDrawGizmosSelected()Empty.
private void OnValidate()Editor: keeps loopInstanceControler at least 1 and, when isToRefresh is ticked, clears the spawned children.
private void SpawnInEditor()Empty in this build.
private IEnumerator Start() (iterator)Coroutine that spawns numberOfClumps clumps at random spots and rotations, each LOD by its chance, then sets up the LOD group.
private void Update()When isToRefresh is set, destroys the children. It calls Start directly, which doesn't run the coroutine, so nothing respawns.