Skip to content

Game.Prefabs.UIHighlight

Assembly:
Game (compiled assembly containing game types; exact assembly name may be "Game" or part of the game's main assembly)

Namespace:
Game.Prefabs

Type:
struct

Base:
Implements: - Unity.Entities.IComponentData
- Unity.Entities.IQueryTypeParameter
- Colossal.Serialization.Entities.IEmptySerializable

Summary:
UIHighlight is an empty/tag ECS component used to mark or tag entities (typically UI-related entities) that should be treated as "highlighted" by systems that process UI highlighting. It is a zero-data marker component — the StructLayout attribute forces a physical size of 1 byte so the component can be stored in chunks even though it carries no payload. Implementing IEmptySerializable indicates it participates in the game's custom serialization pipeline without additional fields.


Fields

  • (none)
    This is an empty/tag component; it declares no instance fields. The StructLayout attribute with Size = 1 causes the struct to occupy 1 byte when stored to ensure it is addressable in native memory and chunk storage.

Properties

  • (none)
    Being a plain tag component it exposes no properties.

Constructors

  • public UIHighlight()
    As a value type (struct), the default parameterless constructor is provided by the runtime. No custom initialization is required or defined.

Methods

  • (none)
    No methods declared. Systems operate on the presence/absence of this component in entity archetypes/queries.

Notes on interfaces and attributes: - StructLayout(LayoutKind.Sequential, Size = 1): Ensures the struct has a deterministic size and layout (1 byte), useful for chunk storage and native interop. - IComponentData: Marks the type as an ECS component that can be attached to entities. - IQueryTypeParameter: Allows the type to be used conveniently in query/filter declarations. - IEmptySerializable: Integrates with Colossal's serialization system as an empty serializable component (no payload to serialize beyond presence).

Usage Example

// Mark an existing entity as highlighted:
EntityManager entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
entityManager.AddComponent<UIHighlight>(someEntity);

// Create an entity that is a UI highlight tag:
EntityArchetype archetype = entityManager.CreateArchetype(typeof(UIHighlight));
Entity highlightEntity = entityManager.CreateEntity(archetype);

// Using an EntityCommandBuffer in a system:
var ecb = new EntityCommandBuffer(Allocator.Temp);
ecb.AddComponent<UIHighlight>(entityToHighlight);
ecb.Playback(entityManager);
ecb.Dispose();

// Query entities that are highlighted in a SystemBase:
Entities
    .WithAll<UIHighlight>()
    .ForEach((Entity e) =>
    {
        // Process highlighted UI entity
    }).Schedule();

Additional guidance: - Because UIHighlight is a tag component, prefer queries using WithAll() or AddComponent/RemoveComponent operations instead of reading data from the component. - The 1-byte size is only to make the empty struct addressable; do not rely on any contained data — none exists. - When serializing/deserializing save data, the presence/absence of this component is what is serialized (IEmptySerializable support).