• Manual
  • Script Reference
Show / Hide Table of Contents
  • UnityEngine.Analytics
    • TutorialManager

Class TutorialManager

A set of methods for managing your game's tutorials.

Inheritance
System.Object
TutorialManager
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ToString()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: UnityEngine.Analytics
Syntax
public class TutorialManager
Remarks

Unity Tutorial Manager (beta) leverages Unity Analytics and Remote Settings to help you build and tune your game's onboarding experience. The ultimate objective is to help you create best-in-class tutorials for your game by optimizing the entire flow. For certain aspects of your tutorial, this means picking the singular best experience. In some cases, the tool can actually deliver different experiences to different players, such that the tutorial is optimized differently based on the different needs of each.

The TutorialManager class provides the interface for accessing and controlling the Tutorial Manager state machine. All the properties and methods are static, so you do not need to construct an instance of the TutorialManager class.

Fields

k_PluginVersion

[Internal Use Only]

Declaration
public static readonly string k_PluginVersion
Field Value
Type Description
System.String

The plugin version as a string.

k_VersionNumber

[Internal Use Only]

Declaration
public static readonly int k_VersionNumber
Field Value
Type Description
System.Int32

The pugin version as an ordinal number.

Properties

autoAdvance

[Read Only] A flag indicating whether the tutorial automatically progresses from one step to the next.

Declaration
public static bool autoAdvance { get; }
Property Value
Type Description
System.Boolean

true if the tutorial automatically advances from one step to the next; otherwise, false.

Remarks

This flag is set to the value of the autoAdvance parameter passed to Start(String, Boolean) when you started the tutorial.

By default, autoAdvance is true and the Tutorial Manager progresses from one step to the next automatically. This automatic progression is often desirable, but not every tutorial works this way. If your game's tutorial has steps interspersed with gameplay, you might want more precise control.

When you start a tutorial by calling Start(tutorialId, false), the Tutorial Manager turns off automatic progression. In this case, calling StepComplete() completes the current step but does not automatically start the next one. This allows gameplay to proceed with the tutorial "paused" between states.

When autoAdvance is false you must call StepStart(String) to start the next step in a tutorial.

complete

[Read Only] A flag indicating whether the current tutorial is complete.

Declaration
public static bool complete { get; }
Property Value
Type Description
System.Boolean

true if the current tutorial is marked as complete; otherwise, false.

showTutorial

[Read Only] Reflects the server recommendation as to whether the player should see the tutorial.

Declaration
public static bool showTutorial { get; }
Property Value
Type Description
System.Boolean

true if the tutorial should be shown; otherwise, false.

state

[Internal Use Only] The current state of the Tutorial Manager.

Declaration
protected static TutorialManagerState state { get; }
Property Value
Type Description
TutorialManagerState

A reference to the TutorialManagerState object.

stepId

[Read Only] The ID of the current tutorial step.

Declaration
public static string stepId { get; }
Property Value
Type Description
System.String

A string representing the ID of the current step.

Remarks

Use the ID with the Start(String, Boolean), StepStart(String), and StepStart(String, String, Boolean) methods.

If you have the stepIndex, you can get the stepId using GetStepIdAtIndex(Int32).

stepIndex

[Read Only] The index of the step in the currently running tutorial.

Declaration
public static int stepIndex { get; }
Property Value
Type Description
System.Int32

The index of the step.

Remarks

You can use GetStepIdAtIndex(Int32) to get the stepId from the stepIndex.

tutorialId

[ReadOnly] The ID of the current tutorial, as set by Start(String, Boolean) or StepStart(String, String, Boolean).

Declaration
public static string tutorialId { get; }
Property Value
Type Description
System.String

The tutorial identifier.

tutorialLength

[ReadOnly] The number of steps in the current tutorial.

Declaration
public static int tutorialLength { get; }
Property Value
Type Description
System.Int32

The length of the tutorial.

Methods

GetDecision()

Retrieves the show/no show recommendation from the Tutorial Manager Server.

Declaration
public static bool GetDecision()
Returns
Type Description
System.Boolean

true, if the tutorial should be shown, false otherwise.

Remarks

This method is the lynchpin of the Tutorial Manager system. It should be called when the player arrives at the first tutorial. Calling it lets you know what recommendation the server has for this player, and informs the server that this recommendation has been acted upon.

If you need to know the decision at any point other than the moment that the player arrives at the decision point, use showTutorial.

if (TutorialManager.GetDecision()) {
    TutorialManager.Start("Tutorial1");
    // Any other code required by your tutorial
} else {
    // skip the tutorial
}

GetDecision(Boolean)

Mimics the show/no show recommendation from the Tutorial Manager service, but overrides with a specific decision.

Declaration
public static bool GetDecision(bool forceDecision)
Parameters
Type Name Description
System.Boolean forceDecision

Set true to force the decision to true; set false otherwise.

Returns
Type Description
System.Boolean

true, if tutorial should be shown, false otherwise.

Remarks

This version takes a boolean forceDecision parameter, which forces either true or false. This is useful for testing and QA, when you want to ensure a specific outcome. To use the server recommendation, call GetDecision().

if (TutorialManager.GetDecision(true)) {
    TutorialManager.Start("Tutorial1", true);
} else {
    // skip the tutorial (since the override in this example is 'true', this code is unreachable)
}

GetStepIdAtIndex(Int32)

Returns the ID of the step at the specified index in the current tutorial.

Declaration
public static string GetStepIdAtIndex(int index)
Parameters
Type Name Description
System.Int32 index

The ordinal step index of a step in the current tutorial.

Returns
Type Description
System.String

A string representing the step ID.

Reset()

Clears the runtime TutorialManager state.

Declaration
public static void Reset()
Remarks

This method is provided for QA and testing purposes only. Calling it will null out all prior decisions and runtime progress on the current device.

Skip()

Skips the current tutorial.

Declaration
public static void Skip()
Remarks

Call Skip() if the player opts to skip the tutorial (in the case you have a skip option in your game). This method clears the current tutorial state. Skip() should only be called after a tutorial has been started.

Start(String, Boolean)

Starts a tutorial.

Declaration
public static void Start(string tutorialId, bool autoAdvance = true)
Parameters
Type Name Description
System.String tutorialId

The ID string of the tutorial to start.

System.Boolean autoAdvance

Set true (default) to advance the tutorial from one step to the next step automatically.

Remarks
if (TutorialManager.GetDecision()) {
    TutorialManager.Start("Tutorial1");
} else {
    // skip the tutorial
}

Starting a tutorial initializes the Tutorial Manager state, sends an event to the Unity Analytics Service, and starts the first step in the specified tutorial.

When you set autoAdvance to true (the default), the Tutorial Manager automatically advances a tutorial to the next step when you call StepComplete(). Otherwise, when you set autoAdvance to false, you must call StepStart(String) to advance the tutorial.

StepComplete()

Completes the current tutorial step.

Declaration
public static void StepComplete()
Remarks

Call StepComplete() each time the player finishes a step in the tutorial.

Completing a tutorial step sends an event to the Unity Analytics Service and turns off any AdaptiveContent and AdaptiveText components associated with the step.

If you started the tutorial with autoAdvance set to true, then this function also starts the next step in the tutorial. Otherwise, you must call StepStart(String) to continue the tutorial.

StepStart(String)

Start a step in the current tutorial.

Declaration
public static void StepStart(string stepId = null)
Parameters
Type Name Description
System.String stepId

(optional) The step of the current tutorial to start. If left null, the Tutorial Manager starts the next step in the tutorial.

Remarks

Call StepStart() each time the player begins a step in the tutorial.

Starting a tutorial step sends an event to the Unity Analytics Service, and enables any AdaptiveContent and AdaptiveText components associated with the step.

It is unnecessary to call this method when the tutorial autoAdvance property is true. Under that condition, StepComplete() starts the next step automatically.

If you provide a specific stepId, that step starts instead of the next step in the tutorial.

StepStart(String, String, Boolean)

Starts the specified step in the specified tutorial.

Declaration
public static void StepStart(string tutorialId, string stepId, bool autoAdvance = true)
Parameters
Type Name Description
System.String tutorialId

The tutorial to go to.

System.String stepId

The step of the new tutorial to start.

System.Boolean autoAdvance

If 'true' (default) ending one tutorial step will automatically advance to the next step.

Remarks

Call this to start a step in some tutorial other than the current one.

Starting the tutorial step resets the Tutorial Manager state based on the specified tutorial, sends the related tutorial and step events to the Unity Analytics Service, and enables any AdaptiveContent and AdaptiveText components associated with the step.

Back to top Generated by DocFX