Game.Tutorials.EditorTutorialSystem
Assembly:
Game
Namespace:
Game.Tutorials
Type:
class
Base:
TutorialSystem
Summary:
A TutorialSystem specialization for the in-game editor (map/asset editor). This system routes tutorial state to the editor-specific SharedSettings (SharedSettings.instance.editor), creates ECS queries that only consider EditorTutorial-marked tutorial entities, and controls whether the tutorial system is active when running in editor game mode. It also initializes the tutorial mode to the list-introduction when appropriate (first editor load or after reset).
Fields
- This class does not declare its own private fields.
This class references several protected fields that are implemented in the base TutorialSystem (for example: m_Setting, m_TutorialQuery, m_ActiveTutorialQuery, m_PendingTutorialListQuery, m_PendingTutorialQuery, m_PendingPriorityTutorialQuery, m_LockedTutorialQuery, m_Mode). Those are initialized/used here to restrict tutorial logic to editor tutorials.
Properties
-
protected override Dictionary<string, bool> ShownTutorials
Overrides the base property to point to the editor-specific storage: SharedSettings.instance.editor.shownTutorials. This dictionary tracks which editor tutorials have already been shown to the user. -
public override bool tutorialEnabled { get; set; }
Getter: returns SharedSettings.instance.editor.showTutorials.
Setter: writes to SharedSettings.instance.editor.showTutorials; if tutorials are turned off (set to false) the system resets base.mode to TutorialMode.Default to cancel any active tutorial mode. This ties the system's enabled state to the persistent editor settings.
Constructors
public EditorTutorialSystem()
Parameterless constructor with Preserve attribute in source. Keeps the type alive for serialization/stripping tools and performs no additional construction logic beyond base class initialization.
Methods
protected override void OnCreate()
: System.Void
Called when the system is created. This override:- Calls base.OnCreate().
- Points m_Setting to SharedSettings.instance.editor so further tutorial logic uses editor settings.
- Creates several EntityQueries that specifically include the EditorTutorial tag/component so the system only processes editor-specific tutorial entities:
- m_TutorialQuery: TutorialData + EditorTutorial
- m_ActiveTutorialQuery: TutorialData + TutorialActive + EditorTutorial
- m_PendingTutorialListQuery: TutorialListData + TutorialRef + TutorialActivated, excludes TutorialCompleted, EditorTutorial
- m_PendingTutorialQuery: TutorialData + TutorialPhaseRef + TutorialActivated, excludes TutorialActive, TutorialCompleted, EditorTutorial
- m_PendingPriorityTutorialQuery: TutorialData + TutorialPhaseRef + TutorialActivated + ReplaceActiveData, excludes TutorialActive, TutorialCompleted, EditorTutorial
- m_LockedTutorialQuery: TutorialData + Locked + EditorTutorial
-
The method is attributed with [Preserve] in source to avoid being stripped.
-
public override void OnResetTutorials()
: System.Void
Clears the editor ShownTutorials dictionary and calls base.OnResetTutorials(). If the current GameManager game mode is an editor, sets m_Mode to TutorialMode.ListIntro so the tutorial list introduction will be shown next. -
protected override void OnGamePreload(Purpose purpose, GameMode gameMode)
: System.Void
Called during preload; calls base and then enables/disables this system depending on whether the provided gameMode.IsEditor() is true. This prevents the system from running in non-editor game modes. -
protected override void OnGameLoadingComplete(Purpose purpose, GameMode gameMode)
: System.Void
Called after game loading completes; calls base and, if the mode is GameMode.Editor, tutorialEnabled is true, and the ListIntro tutorial has not been shown yet (ShownTutorials lacks TutorialSystem.kListIntroKey), sets m_Mode to TutorialMode.ListIntro to trigger the initial list-intro tutorial.
Usage Example
[Preserve]
protected override void OnCreate()
{
base.OnCreate();
// Bind to editor settings so all tutorial queries/logic are editor-scoped
m_Setting = SharedSettings.instance.editor;
// Example: ensure system only runs in editor mode (OnGamePreload also controls this)
base.Enabled = GameManager.instance.gameMode.IsEditor();
}
// Example usage: toggling editor tutorials from code
public void ToggleEditorTutorials(bool enabled)
{
var sys = World.DefaultGameObjectInjectionWorld.GetExistingSystem<EditorTutorialSystem>();
if (sys != null)
{
sys.tutorialEnabled = enabled; // stores preference in SharedSettings.instance.editor.showTutorials
}
}