Skip to content

Game.Prefabs.TutorialObjectPlacementTriggerPrefab

Assembly:
Assembly-CSharp

Namespace:
Game.Prefabs

Type:
public class TutorialObjectPlacementTriggerPrefab

Base:
TutorialTriggerPrefabBase

Summary:
Prefab that defines a tutorial trigger which completes when the player places specified in-game objects. It holds an array of target prefabs (wrapped in ObjectPlacementTarget which includes placement flags), a required count of placements, and implements prefab lifecycle methods to register dependencies, required ECS components, initialize runtime component data, and generate UI blink tags and tutorial links for the editor/prefab tooling.


Fields

  • public ObjectPlacementTarget[] m_Targets
    Array of target entries (see nested ObjectPlacementTarget). Each entry references a PrefabBase that the tutorial cares about and an ObjectPlacementTriggerFlags value describing trigger options.

  • public int m_RequiredCount
    Number of placements required to complete the trigger. During initialization this value is clamped to at least 1.

  • Serializable public class ObjectPlacementTarget
    Nested serializable helper class representing a single target entry:

  • public PrefabBase m_Target — prefab reference to the target object (annotated [NotNull]).
  • public ObjectPlacementTriggerFlags m_Flags — flags controlling trigger behavior for that target.

Properties

  • None specific to this prefab (no public properties are declared).

Constructors

  • public TutorialObjectPlacementTriggerPrefab()
    Default constructor (no explicit constructor in source — the class uses the compiler-provided default). The prefab is normally instantiated by the Unity/Prefab system rather than constructed manually.

Methods

  • public override void GetDependencies(List<PrefabBase> prefabs)
    Adds all prefabs referenced by m_Targets to the provided list of prefab dependencies. Calls base.GetDependencies(prefabs) first. Use: ensures target prefabs are considered dependencies when building or serializing prefabs.

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds required ECS component types for this prefab to the supplied set: ObjectPlacementTriggerData (read/write) and ObjectPlacementTriggerCountData (read/write). Calls base.GetPrefabComponents(components) first. This tells the prefab system which ECS components should be added to the entity representing this prefab.

  • public override void LateInitialize(EntityManager entityManager, Entity entity)
    Performs late initialization once the prefab entity exists:

  • Obtains the DynamicBuffer for the entity.
  • Looks up entities for each referenced target prefab through the PrefabSystem and adds corresponding ObjectPlacementTriggerData entries to the buffer (including flags).
  • Sets ObjectPlacementTriggerCountData on the entity to max(m_RequiredCount, 1). Calls base.LateInitialize(entityManager, entity) first.

  • protected override void GenerateBlinkTags()
    Generates UI blink tags for editor/tutorial visualization:

  • For each target, if the target prefab has a UIObject component and its m_Group is a UIAssetCategoryPrefab with a non-null m_Menu, it adds blink tags for:

    • the target prefab (position index 0),
    • the asset category (position index 1),
    • the category menu (position index 2). Calls base.GenerateBlinkTags() first.
  • public override void GenerateTutorialLinks(EntityManager entityManager, NativeParallelHashSet<Entity> linkedPrefabs)
    Adds Entity links for each target prefab to the given set (used to create tutorial links between prefabs). Uses PrefabSystem to resolve PrefabBase -> Entity and adds them to linkedPrefabs. Calls base.GenerateTutorialLinks(entityManager, linkedPrefabs) first.

Usage Example

// Example: create/configure the prefab in code (typically done in editor/prefab authoring)
var triggerPrefab = someGameObject.AddComponent<Game.Prefabs.TutorialObjectPlacementTriggerPrefab>();

triggerPrefab.m_Targets = new[]
{
    new Game.Prefabs.TutorialObjectPlacementTriggerPrefab.ObjectPlacementTarget
    {
        m_Target = somePrefabReference, // PrefabBase reference to the object to detect placement of
        m_Flags = ObjectPlacementTriggerFlags.None
    }
};

triggerPrefab.m_RequiredCount = 2; // require two placements to complete

// When the prefab is converted/initialized at runtime, LateInitialize will:
// - resolve the target prefab(s) to entities,
// - populate the ObjectPlacementTriggerData buffer on the entity,
// - set ObjectPlacementTriggerCountData with at least 1.

Additional notes: - The prefab integrates with the game's PrefabSystem and ECS (EntityManager, DynamicBuffer, ComponentType). - ObjectPlacementTriggerFlags, ObjectPlacementTriggerData and ObjectPlacementTriggerCountData are ECS-related types used by the trigger systems; their semantics control matching behavior and count tracking at runtime.