Skip to content

Game.Objects.UniqueObject

Assembly: Assembly-CSharp.dll
Namespace: Game.Objects

Type: struct

Base: System.ValueType
Implements: IComponentData, IQueryTypeParameter, IEmptySerializable

Summary:
UniqueObject is an empty, one-byte value-type component used with Unity's ECS in Cities: Skylines 2. It acts as a marker component (a tag) to mark or identify entities without carrying any data. The StructLayout attribute forces a sequential layout with a Size of 1 byte to avoid zero-sized-struct issues for serialization or interop. Implementing IEmptySerializable and IQueryTypeParameter indicates this type is recognized by Colossal's serialization system and can be used directly in ECS query/type parameter contexts.


Fields

  • (none)
    This struct declares no instance fields. Its storage footprint is enforced to 1 byte via the StructLayout attribute.

Properties

  • (none)
    No properties are declared.

Constructors

  • public UniqueObject()
    Structs have an implicit parameterless constructor. An instance of UniqueObject is created with default initialization; the layout attribute ensures it occupies 1 byte.

Methods

  • (none)
    No methods are defined on this type.

Usage Example

// Add the marker to an entity
entityManager.AddComponentData(entity, new Game.Objects.UniqueObject());

// Use it in a System to filter entities that have the marker
public partial class UniqueObjectSystem : SystemBase
{
    protected override void OnUpdate()
    {
        Entities
            .WithAll<Game.Objects.UniqueObject>()
            .ForEach((Entity entity) =>
            {
                // Process entities marked as "unique"
            })
            .Schedule();
    }
}

Additional notes: - Because this is a tag/marker component, prefer using WithAll() / WithNone() or HasComponent() when querying rather than reading data from the component. - The IEmptySerializable implementation and StructLayout(Size = 1) help ensure compatibility with Colossal.Serialization when saving/loading mod data or game state.