Skip to content

Game.Prefabs.ThemeData

Assembly: Game
Namespace: Game.Prefabs

Type: struct

Base: IComponentData, IQueryTypeParameter

Summary:
ThemeData is a tiny marker/tag component used with Unity's ECS in the Cities: Skylines 2 codebase. The struct is explicitly laid out with a size of 1 byte (via StructLayout) which ensures the component has a non-zero size and a predictable layout for native interop or engine/codegen requirements. Implementing IComponentData makes it an ECS component; implementing IQueryTypeParameter indicates it is intended to be used as a query/type parameter in entity queries or generated code paths. Typical usage is to mark entities (prefabs, theme-related entities, or archetypes) as being associated with a theme so systems can query or filter by this tag.


Fields

  • This struct declares no fields.
    The type is intentionally empty and functions as a tag component; the StructLayout attribute sets its runtime size to 1 byte.

Properties

  • This struct declares no properties.

Constructors

  • public ThemeData() (implicit)
    Value types in C# get a default parameterless constructor implicitly. No explicit constructors are defined in the source.

Methods

  • This struct declares no methods.

Usage Example

// Add the tag to an entity via EntityManager:
entityManager.AddComponent<ThemeData>(someEntity);

// In a SystemBase, query for all entities that have the ThemeData tag:
Entities
    .WithAll<ThemeData>()
    .ForEach((Entity e) =>
    {
        // operate on theme-marked entities
    })
    .ScheduleParallel();

// In a Baker (during conversion) add the tag to the baked entity:
public class ThemeBaker : Baker<ThemeAuthoring>
{
    public override void Bake(ThemeAuthoring authoring)
    {
        var entity = GetEntity(TransformUsageFlags.None);
        AddComponent<ThemeData>(entity);
    }
}

Notes: - The StructLayout(LayoutKind.Sequential, Size = 1) attribute is used to force a 1-byte size and a sequential layout. This prevents the type being treated as a zero-sized component by native code or tooling and can avoid certain codegen/interoperability issues. - Because ThemeData carries no payload, use it when you only need to mark/filter entities rather than store per-entity data.