Skip to content

Game.TriggerChirpData

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: struct

Base: System.ValueType, Unity.Entities.IBufferElementData

Summary:
Buffer element type used by Unity DOTS (Entities) to store a reference to a "chirp" entity (typically a sound or trigger prefab). Intended to be used with DynamicBuffer on an entity that needs to hold one or more chirp entity references. Fields must be blittable (Entity is a blittable struct) so the type is safe to use as an IBufferElementData.


Fields

  • public Unity.Entities.Entity m_Chirp
    Holds an Entity reference to the chirp (sound/trigger) prefab or spawned chirp entity. When used in a DynamicBuffer, each element represents one chirp entity associated with the parent entity.

Properties

  • None. This is a simple blittable buffer element struct with a public field.

Constructors

  • public TriggerChirpData()
    Implicit default (value) constructor provided by C#. Instances are typically created inline when adding to a DynamicBuffer, e.g. new TriggerChirpData { m_Chirp = someEntity }.

Methods

  • None. This struct only carries data.

Usage Example

// inside a System that has access to an Entity and wants to add a chirp entity reference
using Unity.Entities;

public partial class ChirpSetupSystem : SystemBase
{
    protected override void OnUpdate()
    {
        Entity someEntity = /* obtain or create the chirp entity */;
        Entities.ForEach((Entity e, int entityInQueryIndex) =>
        {
            var buffer = EntityManager.GetBuffer<TriggerChirpData>(e);
            buffer.Add(new TriggerChirpData { m_Chirp = someEntity });
        }).WithoutBurst().Run();
    }
}

Additional notes: - Use DynamicBuffer to store multiple chirp references per entity. - Ensure the referenced chirp Entity is valid/alive before attempting to use it (check EntityManager.Exists or handle entity lifecycle in systems that consume this buffer).