Skip to content

Game.Prefabs.ObjectGeometryData

Assembly: Game
Namespace: Game.Prefabs

Type: struct

Base: System.ValueType, Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter, Colossal.Serialization.Entities.ISerializable

Summary:
Holds geometric and runtime metadata for a prefab object used by the game's ECS (Entity Component System). It stores axis-aligned bounds (min/max), overall size, pivot, leg (standing) geometry, and several flags and masks that affect rendering, LOD and object requirements. The type implements ISerializable so it can be written to and read from the game's serialized prefab data. Deserialize performs conditional reading of the standing leg offset based on the serialized format tag to maintain backward compatibility.


Fields

  • public Colossal.Mathematics.Bounds3 m_Bounds
    Axis-aligned bounding box for the object. Bounds3 contains min and max fields (both float3). Serialized as two float3 values (min then max).

  • public Unity.Mathematics.float3 m_Size
    Overall size vector of the object (width, height, depth). Serialized after bounds.

  • public Unity.Mathematics.float3 m_Pivot
    Pivot point of the object in local space. Serialized after size.

  • public Unity.Mathematics.float3 m_LegSize
    Size of the object's standing legs (if applicable). Serialized after pivot.

  • public Unity.Mathematics.float2 m_LegOffset
    Offset applied to standing legs. This field is conditionally read during deserialization: Deserialize only reads it if the reader's format has FormatTags.StandingLegOffset. Serialize writes the value (the reader side decides whether to expect it).

  • public GeometryFlags m_Flags
    Geometry-related flags stored as an enum (stored/written as a uint in serialization). Contains flags that influence geometry behavior/rendering.

  • public int m_MinLod
    Minimum LOD level used by the object (used at runtime; declared but not serialized in the shown code).

  • public MeshLayer m_Layers
    Layer(s) this object's mesh belongs to (rendering layer mask; declared but not serialized in the shown code).

  • public ObjectRequirementFlags m_SubObjectMask
    Mask describing required sub-objects or dependencies (declared but not serialized in the shown code).

Properties

This type does not declare any public properties.

Constructors

  • public ObjectGeometryData()
    Default value-type constructor (implicit). As a struct, it can be created with default initialization or by assigning individual fields.

Methods

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads the geometry data from a reader in the following order:
  • bounds.min (float3)
  • bounds.max (float3)
  • size (float3)
  • pivot (float3)
  • legSize (float3)
  • legOffset (float2) — only read if reader.context.format.Has(FormatTags.StandingLegOffset) is true
  • flags (uint) -> cast to GeometryFlags
    Notes:
  • Conditional reading of legOffset allows older serialized formats that do not include the field to be read safely.
  • The method uses by-reference reads into the struct's fields (ref float3 min = ref m_Bounds.min; ...).

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes the geometry data to a writer in the following order:

  • bounds.min (float3)
  • bounds.max (float3)
  • size (float3)
  • pivot (float3)
  • legSize (float3)
  • legOffset (float2)
  • flags (uint) — writes (uint)m_Flags
    Notes:
  • Serialize always writes legOffset. Compatibility is handled on the read side by checking the reader format tag; the presence or interpretation of the field can depend on the reader's format.

Usage Example

// Example: creating and serializing an ObjectGeometryData instance
ObjectGeometryData geo = new ObjectGeometryData();

// Set bounds
geo.m_Bounds.min = new float3(-1f, 0f, -1f);
geo.m_Bounds.max = new float3(1f, 2f, 1f);

// Set other geometry values
geo.m_Size = geo.m_Bounds.max - geo.m_Bounds.min;
geo.m_Pivot = new float3(0f, 0f, 0f);
geo.m_LegSize = new float3(0.1f, 0.5f, 0.1f);
geo.m_LegOffset = new float2(0f, 0f);
geo.m_Flags = GeometryFlags.None;
geo.m_MinLod = 0;
geo.m_Layers = MeshLayer.Default;
geo.m_SubObjectMask = ObjectRequirementFlags.None;

// Serialize (writer is an implementation of IWriter provided by the serialization system)
writer.Write(geo.m_Bounds.min);
writer.Write(geo.m_Bounds.max);
writer.Write(geo.m_Size);
writer.Write(geo.m_Pivot);
writer.Write(geo.m_LegSize);
writer.Write(geo.m_LegOffset);
writer.Write((uint)geo.m_Flags);

// Deserialize (reader is an implementation of IReader provided by the serialization system)
ObjectGeometryData loaded = new ObjectGeometryData();
loaded.Deserialize(reader);

Notes and tips: - Because this struct implements IComponentData, instances can be attached to ECS entities and queried through Entity queries. - The Deserialize method's conditional read of m_LegOffset based on FormatTags.StandingLegOffset is an important backward-compatibility detail — when working with custom writers/readers or custom format versions, ensure the reader.context.format flags match the expected serialized layout. - Several fields (m_MinLod, m_Layers, m_SubObjectMask) exist in the struct but are not touched during serialization/deserialization in the provided code: these are likely set or used at runtime rather than persisted in the prefab binary format.