Skip to content

Game.Tools.Feedback

Assembly: Assembly-CSharp.dll
Namespace: Game.Tools

Type: struct

Base: System.ValueType (implements Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter)

Summary:
Feedback is a lightweight ECS component used to represent transient feedback instances in the game (for example visual or logical feedback tied to gameplay events). It stores the feedback's world position, references to the associated entity and prefab entities, and a deletion flag that systems can use to schedule cleanup or state transitions.


Fields

  • public float3 m_Position
    Position in world space where the feedback is located. Use Unity.Mathematics.float3 to store coordinates (x, y, z).

  • public Entity m_MainEntity
    Reference to the main/gameplay entity associated with this feedback. Can be Entity.Null when not tied to any specific game entity.

  • public Entity m_Prefab
    Prefab entity used for the feedback instance (often the runtime instance or spawned visual). Systems can use this to spawn/identify the concrete feedback representation.

  • public Entity m_MainPrefab
    Reference to the original prefab that represents the type of feedback (e.g., the definition asset). Useful to correlate instances back to their source prefab.

  • public bool m_IsDeleted
    Flag indicating the feedback has been marked for deletion/cleanup. Systems should check this flag to remove or recycle the feedback instance safely in a deterministic manner.

Properties

  • This struct does not declare any C# properties. It exposes only public fields as component data for use with Unity.Entities APIs.

Constructors

  • This struct uses the default value-type constructor provided by C#. No explicit constructors are defined. Initialize instances by setting the fields directly (see usage).

Methods

  • This struct defines no methods. All behavior should be implemented in systems that read or write this component's fields.

Usage Example

using Unity.Entities;
using Unity.Mathematics;
using Game.Tools;

// Create and initialize a feedback entity
void SpawnFeedback(EntityManager entityManager, Entity mainEntity, Entity prefab, Entity mainPrefab, float3 position)
{
    var archetype = entityManager.CreateArchetype(typeof(Feedback));
    Entity feedbackEntity = entityManager.CreateEntity(archetype);

    var feedback = new Feedback
    {
        m_Position = position,
        m_MainEntity = mainEntity,
        m_Prefab = prefab,
        m_MainPrefab = mainPrefab,
        m_IsDeleted = false
    };

    entityManager.SetComponentData(feedbackEntity, feedback);
}

// Example system snippet to remove marked feedback
void CleanupFeedback(SystemBase system)
{
    var ecb = new EntityCommandBuffer(Unity.Collections.Allocator.Temp);
    system.Entities
        .WithAll<Feedback>()
        .ForEach((Entity ent, in Feedback fb) =>
        {
            if (fb.m_IsDeleted)
            {
                ecb.DestroyEntity(ent);
            }
        }).Run();
    ecb.Playback(system.EntityManager);
    ecb.Dispose();
}