Skip to content

Game.Tools.Highlighted

Assembly: Assembly-CSharp (default Unity assembly; actual assembly may vary depending on project/asmdef)
Namespace: Game.Tools

Type: struct (value type)

Base: System.ValueType

Summary:
Highlighted is an empty/tag ECS component used to mark or tag entities as "highlighted" for tooling or rendering purposes. It implements IComponentData so it can be attached to entities in Unity's ECS and IQueryTypeParameter to be usable directly in queries. The StructLayout attribute with Size = 1 ensures the component occupies a non-zero size (1 byte) and has a sequential layout, avoiding issues with zero-sized components in some native/interop scenarios.


Fields

  • None — this struct contains no fields and acts purely as a tag component.
    This minimal footprint is intentional: presence/absence of the component on an entity represents the highlighted state.

Properties

  • None

Constructors

  • public Highlighted()
    Default parameterless constructor (compiler-provided). Use new Highlighted() when adding the component, although simply calling AddComponent() is also common.

Methods

  • None

Usage Example

// Add the tag to an entity
entityManager.AddComponentData(entity, new Highlighted());

// Remove the tag
entityManager.RemoveComponent<Highlighted>(entity);

// Query entities that are highlighted (Entities.ForEach style)
Entities
    .WithAll<Highlighted>()
    .ForEach((Entity e, ref SomeOtherComponent comp) =>
    {
        // process highlighted entities
    })
    .Schedule();

// Alternatively, add/remove in systems
if (shouldHighlight)
    entityManager.AddComponentData(entity, new Highlighted());
else
    entityManager.RemoveComponent<Highlighted>(entity);

Notes: - As a tag component, you typically don't store data on Highlighted — presence alone conveys state. - The StructLayout(Size = 1) ensures a stable, non-zero memory footprint (useful when interoperating with native code or certain ECS internals).