Skip to content

Game.Prefabs.TutorialAreaTriggerPrefab

Assembly:
Assembly-CSharp

Namespace:
Game.Prefabs

Type:
class

Base:
TutorialTriggerPrefabBase

Summary:
Prefab component used to create area-based tutorial triggers. This prefab references one or more AreaPrefab targets and, during prefab initialization, converts those references into AreaTriggerData entries (linking them to actual ECS entities). It also contributes required component types and can generate UI "blink" tags for tutorial highlighting. Typical use is to add tutorial triggers that react to area events (e.g., Created, Modified).


Fields

  • public AreaPrefab[] m_Targets
    Array of AreaPrefab references that this tutorial trigger targets. Marked [NotNull], expected to contain one or more area prefabs. During LateInitialize each referenced AreaPrefab is resolved to an Entity and an AreaTriggerData entry is added for it.

  • public AreaTriggerFlags m_Flags = AreaTriggerFlags.Created | AreaTriggerFlags.Modified
    Flags indicating which area events should trigger the tutorial behavior. Default is a combination of Created and Modified.

Properties

  • This class does not define public properties of its own beyond what it inherits from its base types. (All important data is exposed through the public fields above.)

Constructors

  • public TutorialAreaTriggerPrefab()
    Implicit default constructor. Instances are normally created as prefabs (in-editor or via PrefabSystem) rather than instantiated directly in code.

Methods

  • public override void GetDependencies(List<PrefabBase> prefabs)
    Adds referenced AreaPrefab instances (m_Targets) to the provided dependency list so the prefab system knows these prefabs are required. Calls base.GetDependencies(prefabs) first.

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Registers the runtime/ECS component types this prefab will require. Specifically adds ComponentType.ReadWrite() in addition to base behavior.

  • public override void LateInitialize(EntityManager entityManager, Entity entity)
    Resolves AreaPrefab references to actual Entities using the world's PrefabSystem and populates the entity's DynamicBuffer with AreaTriggerData entries for each resolved target using the configured m_Flags. Calls base.LateInitialize(entityManager, entity) first.

  • protected override void GenerateBlinkTags()
    Generates UI blink tags used by the tutorial system for highlighting UI and assets. Iterates m_Targets; for each AreaPrefab that has a UIObject and whose m_Group is a UIAssetCategoryPrefab with a non-null m_Menu, it calls AddBlinkTagAtPosition for:

  • the areaPrefab.uiTag (position 0),
  • the asset category uiTag (position 1),
  • the category's menu uiTag (position 2). Calls base.GenerateBlinkTags() first.

  • public override void GenerateTutorialLinks(EntityManager entityManager, NativeParallelHashSet<Entity> linkedPrefabs)
    Adds the Entities corresponding to the AreaPrefab targets into the provided linkedPrefabs set (using PrefabSystem.GetEntity) so that the tutorial/link graph knows these prefabs are linked. Calls base.GenerateTutorialLinks(entityManager, linkedPrefabs) first.

Usage Example

// Example: subclassing to add an extra blink tag, or simply rely on the prefab in the editor.
// This shows how you might customize blink tags in code.

public class MyAreaTutorialTriggerPrefab : TutorialAreaTriggerPrefab
{
    protected override void GenerateBlinkTags()
    {
        base.GenerateBlinkTags();

        // Add an additional custom blink tag (position index is arbitrary/contextual).
        // Assume you have an AreaPrefab reference in m_Targets and want to add a tag at position 3.
        if (m_Targets != null && m_Targets.Length > 0 && m_Targets[0] != null)
        {
            AddBlinkTagAtPosition(m_Targets[0].uiTag, 3);
        }
    }
}

// Typical prefab workflow (in editor):
// - Create a TutorialAreaTriggerPrefab asset.
// - Assign one or more AreaPrefab references to m_Targets in the inspector.
// - Choose the AreaTriggerFlags (e.g., Created, Modified) you want to react to.
// At runtime the PrefabSystem will resolve the AreaPrefab references to entities during LateInitialize.

{{ Notes and tips: - m_Targets is expected to be populated in the prefab (Inspector) and is marked [NotNull]. Ensure referenced AreaPrefabs are included as dependencies. - LateInitialize requires that a PrefabSystem exists in the EntityManager.World; otherwise referenced prefabs cannot be resolved to entities. - The class adds AreaTriggerData to the prefab's components so spawned entities will have the necessary buffer to hold target links and flags. - GenerateBlinkTags assumes certain UI-related components exist on the target AreaPrefab (UIObject, UIAssetCategoryPrefab, m_Menu). If those are missing, fewer tags are generated. }}