Skip to content

Game.Tutorials.ObjectSelectionTriggerData

Assembly:
Assembly-CSharp (default Unity game assembly used by Cities: Skylines 2 mods)

Namespace:
Game.Tutorials

Type:
struct

Base:
Unity.Entities.IBufferElementData

Summary:
Represents a single element used in a dynamic buffer that describes an "object selection" trigger for the tutorial system. Each element holds an Entity reference to a prefab (the object to select or highlight) and an Entity reference representing the tutorial phase to transition to when the trigger is activated. This struct is intended to be attached as a DynamicBuffer on a tutorial-related entity so multiple triggers can be stored in order.


Fields

  • public Entity m_Prefab
    Reference to an Entity used as a prefab (the target object to be selected/highlighted). This is typically a prefab Entity created or converted in the ECS world and indicates which object the tutorial expects the player to interact with.

  • public Entity m_GoToPhase
    Reference to the Entity representing the tutorial phase to transition to when this trigger is satisfied. This is used by tutorial systems to advance state/phase logic.

Properties

  • None
    This type contains public fields only. Use the DynamicBuffer API to access elements.

Constructors

  • Default struct constructor
    The default parameterless constructor provided by C# is used. You can create instances via object/collection initialization, for example: new ObjectSelectionTriggerData { m_Prefab = prefabEntity, m_GoToPhase = phaseEntity };

Methods

  • None
    This is a plain data container (IBufferElementData). All manipulation should be done through EntityManager/GetBuffer or via EntityCommandBuffer in jobs/systems.

Usage Notes

  • This type implements IBufferElementData and therefore is intended to be used as a DynamicBuffer attached to an entity:
  • Add the buffer with EntityManager.AddBuffer(entity) or EntityCommandBuffer.AddBuffer(...).
  • Read/write entries using DynamicBuffer.
  • Buffer elements must be blittable and contain only value types (Entity is allowed).
  • When authoring tutorial data in conversion workflows, you can populate this buffer during conversion (ISystem/MonoBehaviour conversion) so the runtime tutorial entity already contains its triggers.
  • In systems, prefer using Entities.ForEach or Jobs that read the DynamicBuffer to evaluate triggers and perform phase transitions (using an EntityCommandBuffer to modify tutorial-phase entities).

Usage Example

// Example: add and populate the buffer for a tutorial entity
protected override void OnCreate()
{
    base.OnCreate();
    var em = World.DefaultGameObjectInjectionWorld.EntityManager;

    // suppose prefabEntity and phaseEntity are obtained/created earlier
    Entity tutorialEntity = em.CreateEntity(); // or fetch an existing tutorial controller entity
    var buffer = em.AddBuffer<ObjectSelectionTriggerData>(tutorialEntity);

    buffer.Add(new ObjectSelectionTriggerData {
        m_Prefab = prefabEntity,
        m_GoToPhase = phaseEntity
    });
}