Skip to content

Game.Prefabs.MeshData

Assembly: Game
Namespace: Game.Prefabs

Type: struct

Base: IComponentData, IQueryTypeParameter

Summary:
MeshData is an ECS component that describes rendering and LOD-related metadata for a mesh used by the game (Cities: Skylines 2). It contains bounds for culling, flags and layer/type masks, LOD and shadow biasing values, smoothing distance, and counts for submeshes, indices and tiling. This struct is intended to be attached to entities representing renderable geometry so systems can perform culling, LOD selection and rendering setup.


Fields

  • public Bounds3 m_Bounds
    Axis-aligned bounding volume for the mesh (from Colossal.Mathematics). Used for frustum/camera culling and overlap tests.

  • public MeshFlags m_State
    Bitmask/flags describing mesh state (e.g., visibility, dynamic/static, special rendering states). Controls runtime behavior for rendering systems.

  • public DecalLayers m_DecalLayer
    Decal layer membership indicating which decal layers this mesh participates in (used when applying decals).

  • public MeshLayer m_DefaultLayers
    Default render layers for the mesh (which rendering layer(s) the mesh normally uses).

  • public MeshLayer m_AvailableLayers
    Layers that the mesh is capable of being rendered on (a superset of default layers used by systems that switch layers).

  • public MeshType m_AvailableTypes
    Types/categories the mesh can represent (e.g., building, road, terrain). Used by rendering and game logic to decide handling.

  • public byte m_MinLod
    Minimum LOD index at which this mesh becomes visible. Lower/zero means visible at highest detail.

  • public byte m_ShadowLod
    LOD index used for shadow rendering. Systems may use this to pick a cheaper LOD for shadow passes.

  • public float m_LodBias
    Bias applied to LOD calculations for this mesh (positive values favor lower detail, negative favor higher detail).

  • public float m_ShadowBias
    Bias applied to LOD selection for shadow rendering separate from main LOD bias.

  • public float m_SmoothingDistance
    Distance used for smoothing transitions (e.g., normal smoothing or LOD blending). Interpreted by relevant rendering systems.

  • public int m_SubMeshCount
    Number of submeshes contained in the mesh. Used to drive draw call setup per submesh.

  • public int m_IndexCount
    Total index count across the mesh (used for statistics, memory estimates, or rendering buffers).

  • public int m_TilingCount
    Tiling repetition count (e.g., how many times textures/UVs tile across the mesh). Affects UV tiled materials and instancing.

Properties

  • This struct has no managed properties; it exposes public fields only and is used as a plain IComponentData value.

Constructors

  • public MeshData()
    As a C# struct, a default parameterless constructor exists implicitly. All fields must be initialized explicitly when creating a value, or rely on the default zeroed values.

Methods

  • This struct defines no methods. It functions purely as data for ECS systems responsible for rendering, culling and LOD selection.

Usage Example

// Create and populate a MeshData component for an entity
var meshData = new MeshData
{
    m_Bounds = new Bounds3(new float3(-1f, -1f, -1f), new float3(1f, 1f, 1f)),
    m_State = MeshFlags.None,
    m_DecalLayer = DecalLayers.Default,
    m_DefaultLayers = MeshLayer.Opaque,
    m_AvailableLayers = MeshLayer.Opaque | MeshLayer.Transparent,
    m_AvailableTypes = MeshType.Building,
    m_MinLod = 0,
    m_ShadowLod = 2,
    m_LodBias = 0.0f,
    m_ShadowBias = 0.0f,
    m_SmoothingDistance = 5.0f,
    m_SubMeshCount = 1,
    m_IndexCount = 36,
    m_TilingCount = 1
};

// Add to an entity using the EntityManager in an ECS system
entityManager.AddComponentData(entity, meshData);