Extending

Everything works without code. For programmers, Shipready is built to be extended.

Control a flow #

flow.Play();            // start (respects Run Once and Resume)
flow.Next();            // finish the current step
flow.Back();
flow.Skip();            // end it and remember it as done
flow.Restart();         // start again from the first step
flow.Stop();            // stop without saving it as done (it resumes next time)
flow.Suspend();         // hold it: nothing shows or blocks, rules and timers wait
flow.Resume();          // show the held step again
flow.RefreshView();     // redraw after changing the look or words at runtime
flow.ClearProgress();   // forget this player's progress for this flow

Read IsRunning, IsSuspended, CurrentIndex, CurrentStep, StepVisible, TargetRect, Device.

Find and start flows from anywhere #

TutorialFlow.PlayById("shop-tour");     // from a button in another scene, a quest, a dialogue...
TutorialFlow.Find("shop-tour");         // the loaded flow with that id, or null
TutorialFlow.SuspendAll(true);          // your pause menu or loading screen opened
TutorialFlow.SuspendAll(false);         // and closed
TutorialFlow.RefreshAllViews();         // the player changed the language

A flow lives in its scene. For a tutorial that goes from the menu into the level, make one flow in each scene and start the second with PlayById (or Start: On Scene Start) after the level loads.

Only one coach-mark flow shows at a time: a second one waits until the first ends (Wait For Other Tutorials, on by default). Hints never wait.

Events and analytics #

Each flow has Started, StepShown, Completed, Skipped (C#) and the matching UnityEvents. For analytics, listen to every flow at once:

TutorialFlow.AnyEvent += e => MyAnalytics.Log("tutorial", e.Kind.ToString(), e.FlowId, e.StepKey, e.ElapsedSeconds);

The kinds are FlowStarted, StepShown, StepCompleted, FlowCompleted, FlowSkipped, FlowStopped, FlowSuspended and FlowResumed. Every flow ends with exactly one of Completed, Skipped or Stopped. StepKey stays the same when you move or insert steps, so your funnels keep working after updates. Shipready itself sends nothing anywhere.

Progress, save slots and profiles #

Progress is saved in PlayerPrefs, which belong to this install of the game. For save slots or several players:

TutorialProgress.UseProfile("slot-2");  // when the player picks a slot, before tutorials start
TutorialProgress.ClearAll();            // "Reset tutorials" in your options, or a new game

Or keep progress in your own save file: implement ITutorialProgressStore (five methods) and set TutorialProgress.Store. Each step saves a stable key with its position, so adding, moving or removing steps in an update never resumes a player at the wrong step (an unknown saved step starts the flow from the beginning).

Targets that appear later #

TutorialTargets.Register("shop.buy", buyButton.transform);
TutorialTargets.Unregister("shop.buy", buyButton.transform);

Or put a Tutorial Target Id component on the prefab. See Targets.

Your own rule #

public sealed class OpenedMapRule : CompletionRule
{
    protected override void OnBegin() => MapScreen.Opened += Done;
    protected override void OnEnd() => MapScreen.Opened -= Done;
    private void Done() => MarkDone();
    public override void DescribeWaiting(System.Text.StringBuilder into) => into.Append("the map to open");
}

Add it to a step like any rule. OnTick runs every frame (real time) while the step shows; OnTargetClicked runs when the player clicks the target. Unsubscribe in OnEnd: it always runs once when the step ends, is skipped or the flow's object is destroyed.

Your own UI #

Implement ITutorialPresenter on a component and put it on the flow's object (or drag it into Presenter). The flow calls ShowStep with everything already resolved (words, look, buttons, icon, position), UpdateTarget every frame with the target's screen rectangle, then HideStep and EndFlow. Call flow.Next(), Back(), Skip() and NotifyTargetClicked() from your buttons. If your UI reports clicks on uGUI targets itself, set flow.TargetReportsClicks = true; otherwise the flow counts a press inside the target. To make your UI the default for every flow, set TutorialPresenters.CreateDefault.

Your own input #

Implement ITutorialInputSource and set TutorialInput.Source to drive tutorials from any input system (Rewired, InControl, your own) or a replay. If players can type somewhere Shipready doesn't know about, add a check so typed letters aren't counted as key presses: TutorialInput.AddTypingCheck(() => myChatBox.IsTyping).

Words #

TutorialText.Translate = key => MyLocalisation.Get(key); and call TutorialFlow.RefreshAllViews() when the language changes.

Condition Rule and IL2CPP #

The Condition Rule reads a field or property by name. With IL2CPP and high code stripping, a member only read this way can be removed: mark it [UnityEngine.Scripting.Preserve], or use an Event Rule for anything the tutorial depends on.

Something unclear or wrong? Tell us · Get help