Game.Objects.Placeholder
Assembly: Game
Namespace: Game.Objects
Type: struct
Base: IComponentData, IQueryTypeParameter, IEmptySerializable
Summary:
Placeholder is an empty, marker (tag) component used to mark entities without storing any runtime data. The struct is annotated with [StructLayout(LayoutKind.Sequential, Size = 1)] to ensure it has a non-zero size for compatibility with serialization systems that expect a minimum size. Implementing IComponentData makes it a Unity ECS component, IQueryTypeParameter allows it to be used in queries as a type parameter, and IEmptySerializable indicates special handling for empty-struct serialization by the Colossal/Unity serialization layers.
Fields
- This type declares no managed fields in source code.
{{ The StructLayout attribute sets the managed size to 1 byte so the empty struct is non-zero-sized for serializers and native layout code. There is no explicit backing field emitted in C# source; the size directive is used to satisfy serialization/native layout requirements. }}
Properties
- This type exposes no properties.
{{ It functions purely as a tag/type marker; use presence/absence of the component on an entity rather than reading/writing data from it. }}
Constructors
- The type has the implicit default parameterless constructor provided by C#.
{{ As a value type (struct), you can create an instance via "new Placeholder()" or use "default(Placeholder)". No custom constructors are defined or required. }}
Methods
- This type defines no methods.
{{ It implements marker/serialization interfaces (IComponentData, IQueryTypeParameter, IEmptySerializable) but does not implement any explicit method bodies here. Behavior is driven by the ECS and serialization frameworks that recognize these interfaces and the struct's presence. }}
Usage Example
// Add the tag to an entity
EntityManager entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
EntityArchetype archetype = entityManager.CreateArchetype(typeof(Game.Objects.Placeholder));
Entity e = entityManager.CreateEntity(archetype);
// Or add to an existing entity
entityManager.AddComponentData(e, new Game.Objects.Placeholder());
// Query by tag in a SystemBase
public partial class ExampleSystem : SystemBase
{
protected override void OnUpdate()
{
// Process all entities that have the Placeholder tag
Entities
.WithAll<Game.Objects.Placeholder>()
.ForEach((Entity ent) =>
{
// Do something for tagged entities
}).ScheduleParallel();
}
}
{{ Notes: - Use Placeholder as a simple marker to classify or filter entities. - The 1-byte size is intentional for serializers that don't accept zero-sized types; do not remove the StructLayout attribute unless you understand the serialization implications. - Because the type carries no data, you shouldn't attempt to read fields from it; presence/absence is the only meaningful information. }}