Class PrefabSpawnRule
Where and how densely a set of prefabs is scattered wherever its texture layer dominates. Field names match the WorldEditor asset layout so exported biome templates load unchanged.
[Serializable]
public class PrefabSpawnRule
- Inheritance
-
PrefabSpawnRule
- Inherited Members
Fields
alignToTerrainNormal
public bool alignToTerrainNormal
Field Value
densityPer100m2
[Header("Density & Limits")]
[Tooltip("Expected prefab count per 100 square meters of dominant texture.")]
[Range(0, 50)]
public float densityPer100m2
Field Value
detailDryColor
[Tooltip("Tint applied when the detail patch is considered dry.")]
public Color detailDryColor
Field Value
- Color
detailHealthyColor
[Tooltip("Tint applied when the detail patch is considered healthy.")]
public Color detailHealthyColor
Field Value
- Color
detailInstancesPerSpawn
[Tooltip("How many instances are written into the detail map for every accepted spawn sample.")]
[Range(64, 255)]
public int detailInstancesPerSpawn
Field Value
detailNoiseSpread
[Header("Detail Rendering")]
[Tooltip("Controls how widely detail prototypes spread noise across the terrain patch.")]
[Range(0.05, 5)]
public float detailNoiseSpread
Field Value
enableSpawning
[Tooltip("Enable or disable this spawn rule without removing configuration.")]
public bool enableSpawning
Field Value
heightFalloff
[Range(0.001, 0.2)]
public float heightFalloff
Field Value
heightRange
public MinMaxRange heightRange
Field Value
heightScaleRange
[Tooltip("Random scale range for tree height (only used when non-uniform scaling is enabled).")]
public Vector2 heightScaleRange
Field Value
- Vector2
maxPerChunk
[Tooltip("Absolute safety cap per terrain chunk. 0 = unlimited (not recommended).")]
[Min(0)]
public int maxPerChunk
Field Value
minSpacing
[Tooltip("Minimum spacing in meters between spawned prefabs.")]
[Range(0, 50)]
public float minSpacing
Field Value
minTextureWeight
[Header("Texture Weight")]
[Tooltip("Require the target texture weight to exceed this threshold in the alphamap to consider spawning.")]
[Range(0, 1)]
public float minTextureWeight
Field Value
prefabs
[Tooltip("List of prefabs to spawn. One will be randomly selected per spawn location for variation.")]
public GameObject[] prefabs
Field Value
- GameObject[]
ruleName
[Header("Identification")]
public string ruleName
Field Value
seedOffset
[Tooltip("Seed offset applied on top of the global prefab seed to keep results deterministic per rule.")]
public int seedOffset
Field Value
slopeFalloff
[Range(1, 20)]
public float slopeFalloff
Field Value
slopeRange
public MinMaxRange slopeRange
Field Value
spawnChannel
[Header("Spawn Channel")]
[Tooltip("Choose whether this rule writes to Unity detail layers or tree instances.")]
public PrefabSpawnChannel spawnChannel
Field Value
spawnProbabilityMultiplier
[Tooltip("Optional multiplier applied to the computed spawn probability.")]
[Range(0.1, 5)]
public float spawnProbabilityMultiplier
Field Value
uniformScaleRange
[Tooltip("Random scale range applied uniformly to width and height (when non-uniform scaling is disabled).")]
public Vector2 uniformScaleRange
Field Value
- Vector2
useHeightConstraint
[Header("Height Constraint")]
public bool useHeightConstraint
Field Value
useNonUniformScaling
[Header("Randomization")]
[Tooltip("Enable independent width and height scaling for more natural tree variation.")]
public bool useNonUniformScaling
Field Value
useSlopeConstraint
[Header("Slope Constraint")]
public bool useSlopeConstraint
Field Value
widthScaleRange
[Tooltip("Random scale range for tree width (only used when non-uniform scaling is enabled).")]
public Vector2 widthScaleRange
Field Value
- Vector2
yRotationRange
public Vector2 yRotationRange
Field Value
- Vector2
Properties
StableGuid
public string StableGuid { get; }
Property Value
Methods
EnsureStableGuid()
public void EnsureStableGuid()
GetRandomPrefab(DeterministicRNG)
One of the rule's prefabs, drawn with the given RNG; null when it has none.
public GameObject GetRandomPrefab(DeterministicRNG rng)
Parameters
rngDeterministicRNG
Returns
- GameObject
HasValidPrefabs()
public bool HasValidPrefabs()