Skip to content

Game.Prefabs.SubMesh

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: struct

Base: IBufferElementData, IEmptySerializable

Summary:
Represents a single sub-mesh entry used by a prefab's buffer in the game's DOTS/ECS workflow. Each SubMesh holds a reference to a mesh Entity plus a local transform (position + rotation), flags controlling behaviour, and a small random seed used for deterministic per-instance variation. The struct is annotated with InternalBufferCapacity(1), indicating an initial capacity optimization when used as a DynamicBuffer element.


Fields

  • public Entity m_SubMesh
    Holds an Entity reference to the sub-mesh (typically an Entity that represents a mesh/prefab to be instantiated or rendered as part of a larger prefab).

  • public float3 m_Position
    Local position offset of the sub-mesh relative to the parent prefab or parent transform.

  • public quaternion m_Rotation
    Local rotation of the sub-mesh relative to the parent prefab or parent transform.

  • public SubMeshFlags m_Flags
    Bitmask/enum controlling sub-mesh behaviour (visibility, rendering options, or other per-submesh flags). The exact semantics depend on the SubMeshFlags definition used elsewhere in the codebase.

  • public ushort m_RandomSeed
    16-bit seed used for deterministic randomization of per-submesh properties (e.g., variant selection, procedural detail) so results are reproducible.

Properties

  • None
    This struct exposes only public fields and does not declare C# properties.

Constructors

  • public SubMesh(Entity mesh, SubMeshFlags flags, ushort randomSeed)
    Initializes a SubMesh that references the given mesh Entity. m_Position is set to float3.zero, m_Rotation to quaternion.identity. Flags and random seed are set from parameters.

  • public SubMesh(Entity mesh, float3 position, quaternion rotation, SubMeshFlags flags, ushort randomSeed)
    Fully-initializing constructor that sets the mesh Entity, local position, local rotation, flags and random seed.

Methods

  • None
    This type is a simple POD-like buffer element without methods beyond the constructors.

Remarks

  • Marked with [InternalBufferCapacity(1)], which reserves space for one element in the entity's DynamicBuffer storage to reduce allocations for common small-buffer cases.
  • Implements IBufferElementData so instances are stored inside DynamicBuffer on an Entity.
  • Implements IEmptySerializable, which indicates compatibility with the game's custom serialization pipeline (Colossal.Serialization.Entities).
  • Typically used as elements of a DynamicBuffer on a parent entity representing a composed prefab (the parent holds a list of its sub-mesh entries).

Usage Example

// Attach or add a DynamicBuffer<SubMesh> to a parent entity and add entries.
Entity parentEntity = /* existing entity */;
Entity subMeshEntity = /* some mesh entity representing the sub-mesh */;
var manager = World.DefaultGameObjectInjectionWorld.EntityManager;

// Ensure the buffer exists
if (!manager.HasComponent<SubMesh>(parentEntity))
{
    manager.AddBuffer<SubMesh>(parentEntity);
}

// Get the buffer and add a SubMesh entry
var buffer = manager.GetBuffer<SubMesh>(parentEntity);
var entry = new SubMesh(subMeshEntity, new float3(0f, 1.0f, 0f), quaternion.identity, SubMeshFlags.None, 12345);
buffer.Add(entry);