Game.FeatureData
Assembly: Game
Namespace: Game.Prefabs
Type: struct
Base: System.ValueType (struct)
Summary:
FeatureData is an empty/tag component used by the game's ECS to mark entities that represent "feature" prefabs. It implements IComponentData so it can be attached to entities and used in queries, and IQueryTypeParameter so it can be used directly in query/filter APIs. The StructLayout attribute with Size = 1 ensures the struct has a non-zero size at runtime (avoiding issues with truly empty structs in some low-level systems and native memory layout scenarios).
Fields
- none
FeatureData declares no instance fields. It is intended to be used purely as a marker/tag component.
Properties
- none
Constructors
- implicit default constructor (
public FeatureData()
implicitly provided)
Because FeatureData is a struct with no explicitly declared constructors, it has the default parameterless constructor that yields the default value. No additional initialization is required.
Methods
- none
Usage Example
// mark an entity as a feature (EntityManager API)
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
entityManager.AddComponentData(featureEntity, new FeatureData());
// query entities that have the FeatureData tag (Systems/Jobs/Entities.ForEach)
Entities
.WithAll<FeatureData>()
.ForEach((Entity e, in SomeOtherComponent comp) =>
{
// handle feature entity
})
.Schedule();
Additional notes: - Because the type is a pure tag, prefer AddComponent/RemoveComponent APIs rather than storing data within it. - The StructLayout(Size = 1) attribute is a deliberate choice to ensure the type occupies at least one byte in native layouts; this can avoid corner cases in native memory or interop code. - Suitable for use in burst-compiled jobs and standard ECS queries/filters.