Skip to content

Game.UI.InGame.TutorialsUISystem

Assembly: Assembly-CSharp (typical for game code)
Namespace: Game.UI.InGame

Type: class

Base: UISystemBase

Summary:
TutorialsUISystem is a UI-facing ECS system that bridges the game's tutorial data and the in-game UI. It exposes tutorial lists, categories, individual tutorials and phases to the UI through bindings, and provides trigger bindings for activating/forcing/completing tutorials and tutorial phases. The system integrates with PrefabSystem, TutorialSystem and dedicated activation/deactivation/trigger systems to reflect and modify tutorial state. It also handles updates when tutorial-related component order versions change and when control scheme changes occur.


Fields

  • internal static class BindingNames
    Contains constant string keys used for UI bindings (e.g. "tutorials", "activeTutorial", "activateTutorialPhase", "controlScheme", etc.). Useful to reference binding names consistently.

  • private enum AdvisorItemType
    Internal enum used to distinguish advisor UI items (Tutorial vs Group).

  • private struct TypeHandle
    Holds ComponentLookup handles used by the system. Used to obtain component lookup instances in burst/compiled sections. Contains:

  • public ComponentLookup<TutorialActivationData> __Game_Tutorials_TutorialActivationData_RW_ComponentLookup

  • private const string kGroup = "tutorials"
    Constant group name used for UI binding namespaces.

  • protected PrefabSystem m_PrefabSystem
    Reference to PrefabSystem for resolving prefab data and names/icons for tutorials, phases and groups.

  • protected ITutorialSystem m_TutorialSystem
    Reference to the main tutorial system (runtime) used to query and manipulate active tutorial, mode, next list tutorial, pending tutorial, etc.

  • private ITutorialSystem m_EditorTutorialSystem
    Editor-specific tutorial system (used when type is EditorTutorialsUISystem).

  • protected ITutorialUIActivationSystem m_ActivationSystem
    System responsible for activating tutorial tags/activation UI logic.

  • protected ITutorialUIDeactivationSystem m_DeactivationSystem
    System responsible for deactivating tutorial tags/systems.

  • protected ITutorialUITriggerSystem m_TriggerSystem
    System responsible for activating/disactivating tutorial triggers.

  • private EntityQuery m_TutorialConfigurationQuery
    EntityQuery (declared but not used directly in provided code; prepared for config queries).

  • private EntityQuery m_TutorialCategoryQuery
    Query to find UI tutorial group entities (UITutorialGroupData + UIObjectData, excluding editor groups).

  • protected EntityQuery m_UnlockQuery
    Query used to check unlocks relevant to tutorial/prefab unlock state.

  • protected RawValueBinding m_ActiveTutorialListBinding
    Binding for the currently active tutorial list; produces structured JSON for UI.

  • protected RawValueBinding m_TutorialCategoriesBinding
    Binding that produces categories data for the UI.

  • private RawMapBinding<Entity> m_TutorialsBinding
    Map binding that binds individual tutorial entities to JSON via BindTutorial.

  • protected RawValueBinding m_ActiveTutorialBinding
    Binding for the currently active tutorial entity (detailed output).

  • protected RawValueBinding m_ActiveTutorialPhaseBinding
    Binding for the currently active tutorial phase.

  • private GetterValueBinding<Entity> m_TutorialPendingBinding
    Binding exposing the currently pending tutorial entity.

  • private int m_TutorialActiveVersion
    Cached component order version for TutorialActive.

  • private int m_PhaseActiveVersion
    Cached component order version for TutorialPhaseActive.

  • private int m_TriggerActiveVersion
    Cached component order version for TriggerActive.

  • private int m_TriggerCompletedVersion
    Cached component order version for TriggerCompleted.

  • private int m_TutorialShownVersion
    Cached component order version for TutorialShown.

  • private int m_PhaseShownVersion
    Cached component order version for TutorialPhaseShown.

  • private int m_PhaseCompletedVersion
    Cached component order version for TutorialPhaseCompleted.

  • private bool m_WasEnabled
    Tracks whether tutorials were enabled previously (used to detect changes and update bindings).

  • private TypeHandle __TypeHandle
    Instance of the TypeHandle struct to store component lookups.

Properties

  • None (this system exposes state via bindings rather than public CLR properties).

Constructors

  • public TutorialsUISystem()
    Default constructor. System is initialized through OnCreate override. The class is also used with the ECS-managed lifecycle and some methods are [Preserve] decorated for IL2CPP.

Methods

  • [Preserve] protected override void OnCreate()
    Initializes the system: disables it by default, retrieves required systems (PrefabSystem, TutorialSystem, Activation/Deactivation/Trigger systems), sets up EntityQueries and registers many UI bindings and trigger bindings for tutorial UI interactions. Also subscribes to InputManager.control scheme changes (when not the editor variant).

  • private void OnControlSchemeChanged(InputManager.ControlScheme controlScheme)
    Event handler called when the control scheme changes; forces update of tutorial bindings (icons/valid phases differ per control scheme).

  • private void CompleteIntro()
    Sets tutorial system mode to Default (used to end intro modes).

  • private void CompleteOutro()
    Sets tutorial system mode to Default (used to end outro/list outro).

  • [Preserve] protected override void OnUpdate()
    Main update tick: checks component order versions for tutorial-related components and updates the corresponding bindings when state changes (active/completed/shown triggers etc.). Also updates category and tutorials bindings when unlocks change or when tutorial enable state changed. Updates pending binding. Caches the observed versions.

  • private void BindCategories(IJsonWriter writer)
    Writes tutorial categories (top-level groups) to the provided Json writer. Resolves names and flags (shown/force/locked) via PrefabSystem and ECS components. Calls BindTutorialGroup for children.

  • protected void BindTutorialGroup(IJsonWriter writer, Entity entity)
    Recursively writes a tutorial group or list children. Iterates UIGroupElement buffers and writes per-child info (entity, name, icon, type, shown, force, locked and children).

  • private NativeList<UIObjectInfo> GetSortedCategories(Allocator allocator)
    Collects top-level categories from m_TutorialCategoryQuery, filters those with no parent, sorts them by priority and returns a NativeList.

  • protected void BindActiveTutorialList(IJsonWriter writer)
    Writes the currently active tutorial list (if any) to the writer, including visible tutorials and hint tutorials (phases shown vs not shown), intro flag and basic info.

  • private NativeList<Entity> GetVisibleListTutorials(Entity listEntity, Allocator allocator)
    Returns tutorials in a TutorialList whose TutorialActivationData component is NOT present (so they are visible as non-activated items).

  • private NativeList<Entity> GetListHintTutorials(Entity listEntity, Allocator allocator)
    Returns tutorials in a TutorialList whose TutorialActivationData component IS present (these become hints).

  • private bool AlternativeCompleted(Entity tutorial)
    Checks if any alternative tutorial (TutorialAlternative buffer) is completed for a given tutorial entity. Used to indicate completion even if the tutorial itself isn't directly completed.

  • protected void BindTutorial(IJsonWriter writer, Entity tutorialEntity)
    Writes an individual tutorial's details to JSON (name, icon, locked, priority, active/completed/shown/force/mandatory flags, list of phases (filtered by control scheme), filters and alternatives). Uses PrefabSystem and ECS components/buffers.

  • protected void BindTutorialPhase(IJsonWriter writer, Entity phaseEntity)
    Writes details for a tutorial phase: name, type, active/shown/force/completed flags, whether forces completion, if it's a branch, images/icons, balloon UI targets (if a balloon prefab), control scheme, and trigger info (name, blink tags, displayUI, active/completed/preCompleted and phase branching).

  • private void ActivateTutorial(Entity tutorial)
    Requests the tutorial system to set the active tutorial (tutorial, no explicit phase).

  • private void ActivateTutorialPhase(Entity tutorial, Entity phase)
    Requests the tutorial system to set the active tutorial and phase.

  • private void ForceTutorial(Entity tutorial, Entity phase, bool advisorActivation)
    Requests the tutorial system to force start a tutorial/phase, optionally forcing advisor activation.

  • protected virtual void CompleteActiveTutorialPhase()
    Completes current tutorial phase if in a game mode (checks GameManager.instance.gameMode.IsGame()). Virtual so editor/system variants can override.

  • private void CompleteActiveTutorial()
    Marks the active tutorial as completed via the tutorial system.

  • private void CompleteIntro(bool tutorialEnabled)
    Sets tutorial mode to Default and updates tutorialEnabled according to the passed flag. Used when completing intro sequences with option to toggle tutorial enable.

  • private void OnSetTutorialTagActive(string tag, bool active)
    Sets a tutorial UI activation tag via the activation system and deactivates that tag in the deactivation system if set to false.

  • private void ActivateTutorialTrigger(string trigger)
    Activates a tutorial trigger via the trigger system.

  • private void DisactivateTutorialTrigger(string trigger)
    Disactivates a tutorial trigger via the trigger system.

  • private static string[] GetFilters(TutorialPrefab prefab)
    Returns filter strings for a tutorial prefab (currently only returns control scheme name if TutorialControlSchemeActivation is present).

  • protected override void OnGameLoadingComplete(Purpose purpose, GameMode gameMode)
    Enables the system when the game or editor mode is active (base.Enabled = gameMode.IsGameOrEditor()).

  • [MethodImpl(MethodImplOptions.AggressiveInlining)] private void __AssignQueries(ref SystemState state)
    Compiler helper to assign queries (in this implementation it creates/disposes an EntityQueryBuilder; used by OnCreateForCompiler).

  • protected override void OnCreateForCompiler()
    Compiler-time initialization, assigns queries and assigns handles from __TypeHandle.

  • [Preserve] public TutorialsUISystem()
    Default constructor (declared and preserved for IL2CPP).

Usage Example

[Preserve]
protected override void OnCreate()
{
    base.OnCreate();
    // Typical initialization done by the system:
    base.Enabled = false;
    m_PrefabSystem = base.World.GetOrCreateSystemManaged<PrefabSystem>();
    m_TutorialSystem = base.World.GetOrCreateSystemManaged<TutorialSystem>();
    m_ActivationSystem = base.World.GetOrCreateSystemManaged<TutorialUIActivationSystem>();
    m_DeactivationSystem = base.World.GetOrCreateSystemManaged<TutorialUIDeactivationSystem>();
    m_TriggerSystem = base.World.GetOrCreateSystemManaged<TutorialUITriggerSystem>();

    // Bindings are registered here (see full method in source).
}

Notes and tips: - The UI communicates with this system via the registered RawValueBinding/RawMapBinding and TriggerBinding keys (BindingNames constants). Use those keys to call activate/complete/force operations from UI JavaScript. - Many Bind* methods expect Prefab data and ECS components to be present; ensure PrefabSystem and tutorial prefabs exist for entities passed to bindings. - Control-scheme-specific phase filtering is handled via TutorialSystem.IsValidControlScheme and the TutorialControlSchemeActivation component.