Skip to content

Game.Tutorials.AreaTriggerData

Assembly: Assembly-CSharp
Namespace: Game.Tutorials

Type: struct

Base: Unity.Entities.IBufferElementData

Summary:
Represents a single element of a DynamicBuffer that describes an area trigger used by the tutorial system. Each element pairs a prefab Entity (the thing to spawn or reference when the trigger is activated) with a set of flags (AreaTriggerFlags) that control trigger behavior (for example, whether it is one‑time, repeatable, or has other custom behavior). This type is a plain data container intended to be stored in an Entity's DynamicBuffer.


Fields

  • public Entity m_Prefab
    Holds an Entity reference to the prefab associated with this trigger. The referenced Entity is typically a prefab converted to an entity (e.g., via authoring/ConvertToEntity) that the tutorial system will instantiate or otherwise use when the trigger activates.

  • public AreaTriggerFlags m_Flags
    Flags that configure the trigger's behavior. AreaTriggerFlags is an enum (not shown here) that encodes options such as one-shot vs. repeatable, visibility, or other tutorial-specific controls.

Properties

  • This type defines no properties. It exposes two public fields for use as a buffer element.

Constructors

  • public AreaTriggerData(Entity prefab, AreaTriggerFlags flags)
    Creates a new AreaTriggerData element, initializing the prefab reference and the trigger flags.

Methods

  • This struct defines no methods. It is a simple data holder implementing IBufferElementData and is intended to be used in DynamicBuffer.

Usage Example

// Example inside a SystemBase or other code with access to EntityManager
Entity tutorialEntity = /* obtain or create the entity that owns the buffer */;
Entity prefabEntity = /* prefab converted to entity */;
AreaTriggerFlags flags = AreaTriggerFlags.TriggerOnce; // example value

// Ensure the entity has a DynamicBuffer<AreaTriggerData>
if (!EntityManager.HasBuffer<AreaTriggerData>(tutorialEntity))
{
    EntityManager.AddBuffer<AreaTriggerData>(tutorialEntity);
}

var buffer = EntityManager.GetBuffer<AreaTriggerData>(tutorialEntity);
buffer.Add(new AreaTriggerData(prefabEntity, flags));

{{ Additional notes: - Because this is an IBufferElementData, it is meant to be used with Unity's ECS DynamicBuffer APIs. - Ensure prefabs referenced by m_Prefab are converted to entities and remain valid for the lifetime of the tutorial/trigger usage. - AreaTriggerFlags controls behavior; consult its definition in the codebase for available options and exact semantics. }}