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
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