Skip to content

Game.Prefabs.TerrainComposition

Assembly: Assembly-CSharp (game's main assembly; exact assembly may vary)
Namespace: Game.Prefabs

Type: struct

Base: IComponentData, IQueryTypeParameter

Summary:
TerrainComposition is a small ECS component that stores per-entity offset values used by the game's terrain composition logic. It holds 2D offsets for width and clip height and 3D minimum/maximum height offsets. As an IComponentData it is a plain value type designed to be attached to entities; implementing IQueryTypeParameter indicates it can be used directly in ECS query APIs.


Fields

  • public Unity.Mathematics.float2 m_WidthOffset
    Stores a 2D offset related to the terrain's width dimensions. Typical usage is to nudge or shift procedural terrain composition along X/Y axes. Both components default to 0 when the struct is default-initialized.

  • public Unity.Mathematics.float2 m_ClipHeightOffset
    A 2D value representing clip-height offsets (for example lower/upper clip or min/max clip thresholds). The exact interpretation depends on the terrain composition system consuming this data — commonly used to adjust vertical clipping behavior.

  • public Unity.Mathematics.float3 m_MinHeightOffset
    Per-axis minimum height offsets (X, Y, Z). Used to lower or bias the minimum local heights applied by the terrain composition logic. Defaults to zero on default initialization.

  • public Unity.Mathematics.float3 m_MaxHeightOffset
    Per-axis maximum height offsets (X, Y, Z). Used to raise or bias the maximum local heights applied by the terrain composition logic. Defaults to zero on default initialization.

Properties

  • None. This type exposes only public fields.

Constructors

  • public TerrainComposition()
    The default parameterless constructor (auto-generated). All float components default to 0. Use object initializer syntax to set desired offsets.

Methods

  • None. This is a pure data container (blittable) type with no behavior.

Usage Example

using Unity.Entities;
using Unity.Mathematics;
using Game.Prefabs;

// Create an entity and attach TerrainComposition with custom offsets
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
var archetype = entityManager.CreateArchetype(typeof(TerrainComposition));
var entity = entityManager.CreateEntity(archetype);

var terrainComp = new TerrainComposition
{
    m_WidthOffset = new float2(1.0f, -0.5f),
    m_ClipHeightOffset = new float2(0.0f, 10.0f),
    m_MinHeightOffset = new float3(-2.0f, 0f, -2.0f),
    m_MaxHeightOffset = new float3(2.0f, 0f, 2.0f)
};

entityManager.SetComponentData(entity, terrainComp);

// Or on an existing entity:
// entityManager.SetComponentData(existingEntity, new TerrainComposition { ... });

Notes: - Because this is an IComponentData struct it must remain a value type containing only blittable fields. - The semantic meaning of each offset (units, which axis they apply to, min vs max) is determined by the terrain composition system that reads this component; check that system's code or documentation for precise interpretation.