Skip to content

Game.Prefabs.TutorialPhasePrefab

Assembly: Game
Namespace: Game.Prefabs

Type: abstract class

Base: PrefabBase

Summary:
TutorialPhasePrefab is an abstract base prefab used by the game's tutorial system to represent a single "phase" or step in a tutorial flow. It stores presentation data (image, platform-specific overrides, icon, visibility flags), control-scheme targeting, optional trigger prefab reference, and an optional completion-delay override. The prefab is responsible for declaring the ECS components that will be added to the instantiated entity (TutorialPhaseData and, when applicable, TutorialTrigger and TutorialPhaseCanDeactivate) and for resolving referenced trigger prefabs into entity references during LateInitialize. Use this class as the base for concrete tutorial-phase prefabs that compose tutorial sequences.


Fields

  • public enum ControlScheme { KeyboardAndMouse = 1, Gamepad = 2, All = 3 }
    {{ The ControlScheme enum indicates which input scheme(s) the tutorial phase applies to. Use KeyboardAndMouse, Gamepad, or All to restrict or allow the phase based on the current control input. }}

  • public string m_Image
    {{ Path/identifier of the default image shown for the tutorial phase (UI/tutorial art). This is the general image used unless a platform-specific override is provided. }}

  • public string m_OverrideImagePS
    {{ Optional image override used for PlayStation (PS) builds/skins. If set, this image replaces m_Image for that platform. }}

  • public string m_OverrideImageXBox
    {{ Optional image override used for Xbox builds/skins. If set, this image replaces m_Image for that platform. }}

  • public string m_Icon
    {{ Small icon asset name/path shown for the tutorial phase (for list entries, headers, etc.). }}

  • public bool m_TitleVisible = true
    {{ Controls whether the tutorial phase's title is shown in the UI. Default is true. }}

  • public bool m_DescriptionVisible = true
    {{ Controls whether the tutorial phase's description/body text is shown in the UI. Default is true. Note: field was formerly serialized as "m_ShowDescription". }}

  • public bool m_CanDeactivate
    {{ When true, the instantiated entity will receive a TutorialPhaseCanDeactivate component so the phase can be deactivated programmatically (or signalled to end). If false, the phase is not marked as deactivatable. }}

  • public ControlScheme m_ControlScheme = ControlScheme.All
    {{ Which control schemes this tutorial phase supports. Default allows all input schemes. The game can use this to hide or skip phases not relevant to the current input method. }}

  • [CanBeNull] public TutorialTriggerPrefabBase m_Trigger
    {{ Optional reference to a trigger prefab that controls when/if this tutorial phase activates. If set, that trigger prefab is considered a dependency and will be resolved into a TutorialTrigger component on the entity. Can be null for simple phases without triggers. }}

  • public float m_OverrideCompletionDelay = -1f
    {{ Optional override for the phase's completion delay (in seconds). A negative value (default -1) typically indicates "no override" and the system's default delay should be used. }}

Properties

  • public override bool ignoreUnlockDependencies => true
    {{ This prefab overrides ignoreUnlockDependencies to true, meaning tutorial-phase prefabs ignore normal unlock dependencies. Tutorials are generally available regardless of player unlock progression. }}

Constructors

  • public TutorialPhasePrefab()
    {{ No explicit constructor is defined in the source (default parameterless constructor). Concrete tutorial-phase prefabs typically rely on field initializers to set defaults or set fields in their own constructors. }}

Methods

  • public override void GetDependencies(System.Collections.Generic.List<PrefabBase> prefabs)
    {{ Adds referenced prefabs to the dependency list. Implementation calls base.GetDependencies(prefabs) and, if m_Trigger is set, adds that trigger prefab instance to prefabs so the trigger is included/loaded when this prefab is used. Use this to ensure referenced trigger prefabs are available at load/instantiate time. }}

  • public override void GetPrefabComponents(System.Collections.Generic.HashSet<Unity.Entities.ComponentType> components)
    {{ Declares the ECS component types that should be added to an entity created from this prefab. Always adds TutorialPhaseData; adds TutorialTrigger if m_Trigger is set; adds TutorialPhaseCanDeactivate if m_CanDeactivate is true. This ensures the instantiated entity has the necessary data/markers consumed by the tutorial systems. }}

  • public override void LateInitialize(Unity.Entities.EntityManager entityManager, Unity.Entities.Entity entity)
    {{ Called late in prefab initialization to resolve references that require runtime systems. If the entity has a TutorialTrigger component, this method looks up the PrefabSystem and replaces the m_Trigger reference on the component with the entity value returned by PrefabSystem.GetEntity(m_Trigger). This binds the trigger prefab reference to the actual trigger entity in the world. }}

  • public virtual void GenerateTutorialLinks(Unity.Entities.EntityManager entityManager, Unity.Collections.NativeParallelHashSet<Unity.Entities.Entity> linkedPrefabs)
    {{ Optional hook to generate links between tutorial-related prefabs for graphing or load ordering. The default implementation delegates to m_Trigger.GenerateTutorialLinks(entityManager, linkedPrefabs) when a trigger is set. Override to add additional linking logic (for example, linking to other phases or resources). }}

Usage Example

// Example concrete tutorial phase prefab
public class BuildRoadsTutorialPhasePrefab : TutorialPhasePrefab
{
    public BuildRoadsTutorialPhasePrefab()
    {
        m_Image = "UI/Tutorials/BuildRoads";
        m_Icon = "Icons/Tutorial_Road";
        m_TitleVisible = true;
        m_DescriptionVisible = true;
        m_CanDeactivate = true;
        m_ControlScheme = ControlScheme.All;
        m_OverrideCompletionDelay = -1f;
        // m_Trigger could be assigned here (from an asset or created prefab)
    }

    public override void GenerateTutorialLinks(EntityManager entityManager, NativeParallelHashSet<Entity> linkedPrefabs)
    {
        // Keep default trigger linking
        base.GenerateTutorialLinks(entityManager, linkedPrefabs);

        // Add additional link logic if needed
        // e.g. link to a follow-up phase prefab entity if present
    }
}

{{ Notes and tips: - When authoring a prefab asset derived from TutorialPhasePrefab, set m_Trigger to a TutorialTrigger prefab if the phase should be activated by in-game conditions. The trigger will be resolved to an entity reference during LateInitialize. - Use m_OverrideImagePS / m_OverrideImageXBox for platform-specific artwork when needed. - If you want the phase to be programmatically dismissible, set m_CanDeactivate = true so the TutorialPhaseCanDeactivate component appears on the entity. - The prefab declares necessary ECS components; systems in the tutorial flow will read TutorialPhaseData and TutorialTrigger to manage lifecycle. }}