Skip to content

Game.Error

Assembly: Assembly-CSharp (typical Unity game assembly)
Namespace: Game.Tools

Type: struct

Base: System.ValueType; implements Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter

Summary:
Error is a marker/tag ECS component (an empty struct) used to mark entities that are in an error state. The type is decorated with [StructLayout(LayoutKind.Sequential, Size = 1)] to guarantee a non-zero, fixed size (1 byte) for interop/blittable requirements even though it declares no fields. Because it implements IComponentData it can be added to entities; because it implements IQueryTypeParameter it can be used directly in entity queries (WithAll/WithNone/etc). This type contains no payload — presence/absence of the component is the information.


Fields

  • This struct defines no fields.
    The StructLayout attribute sets Size = 1 so the runtime will allocate 1 byte for instances even though there are no declared fields. This is commonly done for empty/tag components to avoid zero-sized-type edge cases.

Properties

  • This struct defines no properties.

Constructors

  • The struct has the implicit default parameterless constructor (new Error()), which yields the default tag instance. No explicit constructors are declared.

Methods

  • This struct declares no methods. It is a plain data/tag component meant solely for presence checks.

Usage Example

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

// Remove the tag when the error is cleared
entityManager.RemoveComponent<Error>(entity);

// Query entities that currently have the error tag
Entities.WithAll<Error>().ForEach((Entity e, ref SomeOtherComponent comp) =>
{
    // handle entities marked with Error
});

// Use in a system To filter by presence/absence
public partial class ErrorHandlerSystem : SystemBase
{
    protected override void OnUpdate()
    {
        Entities.WithAll<Error>().ForEach((Entity e) =>
        {
            // react to errored entities
        }).Schedule();
    }
}

Notes: - Because Error is an empty/tag component, store only presence/absence; do not expect any payload data. - The 1-byte size ensures compatibility with certain APIs or serialization paths that don't accept zero-sized types.