Game.Common.Created
Assembly: Assembly-CSharp
Namespace: Game.Common
Type: struct
Base: System.ValueType, implements Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter
Summary: A zero-data "tag" component used to mark entities that were created (or should be treated as newly created) for query/filtering purposes. The struct is explicitly laid out with Size = 1 to ensure it occupies a minimal, non-zero amount of memory while remaining effectively empty. Typical uses include one-frame initialization flags or filtering entities in queries/iterations (e.g., to run setup logic only on newly created entities).
Fields
- This struct defines no instance fields. It is an empty/tag component; the StructLayout(Size = 1) attribute is used to give it a minimal size at runtime.
Additional info: - Using a 1-byte size is a common pattern for tag components in Unity.Entities to avoid zero-size types while keeping memory overhead minimal.
Properties
- This type exposes no properties.
Additional info: - As a tag component, it only serves as a marker; there is no stored state to expose via properties.
Constructors
- public Created() This is the implicit parameterless constructor for the value type (struct). No custom initialization is required or performed.
Additional info: - You do not normally need to call or implement a constructor for this tag component. The ECS-created entities will have the component present without additional data.
Methods
- This struct declares no methods.
Additional info:
- It implements IQueryTypeParameter to be usable directly in query/filter APIs (e.g., WithAll
Usage Example
using Unity.Entities;
using Game.Common;
// Create an entity with the Created tag
var em = World.DefaultGameObjectInjectionWorld.EntityManager;
var archetype = em.CreateArchetype(typeof(Created), /* other component types */);
Entity e = em.CreateEntity(archetype);
// Or add the tag to an existing entity
em.AddComponent<Created>(someEntity);
// Sample system usage: only process entities that have the Created tag
public partial class ExampleSystem : SystemBase
{
protected override void OnUpdate()
{
Entities
.WithAll<Created>()
.ForEach((Entity entity, int entityInQueryIndex /*, other components */) =>
{
// Initialization logic for newly created entities here
// Remove the Created tag so the logic runs only once
EntityManager.RemoveComponent<Created>(entity);
}).Schedule();
}
}
Additional info:
- Common pattern: mark entities with Created when constructing them, run one-frame initialization in a system that queries WithAll