Cheatsheet
Tutorial Master Manager
Builder class: TutorialMasterManagerBuilder
using WorldTools.TutorialMaster.Core.Builders;
using WorldTools.TutorialMaster.Core.Components;
using WorldTools.TutorialMaster.Core.Data;
// 1
var builder = new TutorialMasterManagerBuilder()
.AddTutorial(TODO)
.SetName("Canvas_TutorialMasterManager");
// 2
TutorialMasterManager tutorialMasterManager = builder.Build();
- Creating an instance of
TutorialMasterManagerBuilder
will create an empty GameObject with the following components:
TutorialMasterManager
(disabled)Canvas
- sorting order set to maximum value (32767)
- shader channels set to None
CanvasScaler
GraphicRaycaster
- Calling
.Build()
is going to enableTutorialMasterManager
, which should trigger itsStart()
.
Tutorials
Builder class: TutorialBuilder
using WorldTools.TutorialMaster.Core.Builders;
using WorldTools.TutorialMaster.Core.Components;
using WorldTools.TutorialMaster.Core.Data;
Tutorial tutorial = new TutorialBuilder()
.SetName("Blacksmith tutorial")
.AddStage(TODO)
// variable collection has its own builder
.SetupVariables(variableBuilder => variableBuilder
.AddVariable(name: "apple_count", initialValue: 10, resetBetweenStages: false)
)
.Build();
Stages
Builder class: StageBuilder
using WorldTools.TutorialMaster.Core.Builders;
using WorldTools.TutorialMaster.Core.Data;
var stageBuilder = new StageBuilder();
<...>
Stage stage = stageBuilder.Build();
Adding actions
Parallel actions
If you want all your actions to run in parallel.
using WorldTools.TutorialMaster.Core.Builders;
using WorldTools.TutorialMaster.Core.Data;
Stage stage = new StageBuilder()
.AddEnterAction(chainBuilder => chainBuilder
.AddNext<ActionBuilders.Wait>(b => b.SetWaitDuration(2))
)
.AddEnterAction(chainBuilder => chainBuilder
.AddNext<ActionBuilders.Wait>(b => b.SetWaitDuration(5))
)
.AddEnterAction(chainBuilder => chainBuilder
.AddNext<ActionBuilders.Wait>(b => b.SetWaitDuration(10))
)
.Build();
You can also use AddEnterActionForEach
to add multiple parallel actions in a single call.
using WorldTools.TutorialMaster.Core.Builders;
using WorldTools.TutorialMaster.Core.Components;
using WorldTools.TutorialMaster.Core.Data;
var waitDurationCollection = new int[] { 2, 5, 10 };
Stage stage = new StageBuilder()
.AddEnterActionForEach(waitDurationCollection, (waitDuration, chainBuilder) => chainBuilder
.AddNext<ActionBuilders.Wait>(actionBuilder => actionBuilder
.SetWaitDuration(waitDuration)
))
.Build();
Sequential actions
If you want all your actions to run sequentially.
using WorldTools.TutorialMaster.Core.Builders;
using WorldTools.TutorialMaster.Core.Data;
Stage stage = new StageBuilder()
.AddEnterAction(chainBuilder => chainBuilder
.AddNext<ActionBuilders.Wait>(b => b.SetWaitDuration(2))
.AddNext<ActionBuilders.Wait>(b => b.SetWaitDuration(5))
.AddNext<ActionBuilders.Wait>(b => b.SetWaitDuration(10))
)
.Build();
You can also use AddNextForEach
to add same sequential actions in a single call.
using WorldTools.TutorialMaster.Core.Builders;
using WorldTools.TutorialMaster.Core.Data;
var waitDurationCollection = new int[] { 5, 5, 10 };
Stage stage = new StageBuilder()
.AddEnterAction(chainBuilder => chainBuilder
.AddNextForEach<ActionBuilders.Wait, int>(waitDurationCollection, (waitDuration, chainBuilder) => chainBuilder
.SetWaitDuration(waitDuration)
)
)
.Build();
Adding events
Invoke actions sequentially
using WorldTools.TutorialMaster.Core.Builders;
using WorldTools.TutorialMaster.Core.Data;
Stage stage = new StageBuilder()
.AddEvent<EventBuilders.ButtonClick>(eventBuilder => eventBuilder
.SetButton(gameObjectButton)
.OnEventInvoke(chainBuilder => chainBuilder
.AddNext<ActionBuilders.Wait>()
.GoNextStage()
)
)
.Build();
Invoke actions in parallel
using WorldTools.TutorialMaster.Core.Builders;
using WorldTools.TutorialMaster.Core.Data;
var unityMethod = new UnityEvent();
unityMethod.AddListener(() =>
{
Debug.Log("Event was triggered!");
});
Stage stage = new StageBuilder()
.AddEvent<EventBuilders.ButtonClick>(eventBuilder => eventBuilder
.SetButton(gameObjectButton)
.OnEventInvoke(chainBuilder => chainBuilder
.AddNext<ActionBuilders.Wait>()
.GoNextStage()
)
.OnEventInvoke(chainBuilder => chainBuilder
.AddNext<ActionBuilders.PlayAudioClip>(builder => builder
.SetAudioClip(audioClipToPlay)
)
)
.OnEventInvoke(chainBuilder => chainBuilder
.AddNext<ActionBuilders.InvokeMethod>(builder => builder
.SetMethod(unityMethod)
)
)
)
.Build();
Spawning markers
Getting Marker Pool
Spawning a marker requires a marker pool id. Assuming you have Tutorial Master Manager component with a Marker Pool Registry already setup (if not, refer to this guide), you can get the marker pool reference like so:
using WorldTools.TutorialMaster.Core.Data.Pooling;
MarkerPoolId markerPool = m_TutorialMasterManager.MarkerPoolingSystem.Registry.FindByName("marker_pool_name").Id;
Spawning built-in marker
using WorldTools.TutorialMaster.Core.Builders;
using WorldTools.TutorialMaster.Core.Data;
using WorldTools.TutorialMaster.Core.Data.Pooling;
MarkerPool markerPool = m_TutorialMasterManager.MarkerPoolingSystem.Registry.FindByName("marker_pool_name");
Stage stage = new StageBuilder()
.AddEnterAction(chainBuilder => chainBuilder
.AddNext<ActionBuilders.SpawnPointerMarker>(spawnMarkerBuilder => spawnMarkerBuilder
// marker-specific builder methods must be defined first
.PointAt(PointDirection.Down)
// followed by generic builder methods
.SetPositionByAnchors(Alignment.Top)
.SetMarkerPool(markerPool.Id)
)
)
.Build();
Spawning custom marker
Custom markers do not have fancy builder methods. Instead, SetDerivedSettings
must be used.
using WorldTools.TutorialMaster.Core.Builders;
using WorldTools.TutorialMaster.Core.Data;
using WorldTools.TutorialMaster.Core.Data.Pooling;
class CustomMarkerSettings : DerivedMarkerSettings
{
public string Text;
}
<...>
Stage stage = new StageBuilder()
.AddEnterAction(chainBuilder => chainBuilder
.AddNext<ActionBuilders.SpawnMarker>(spawnMarkerBuilder => spawnMarkerBuilder
.SetDerivedSettings(new CustomMarkerSettings
{
Text = "Hello world",
})
.SetPositionByAnchors(Alignment.Top)
.SetMarkerPool(markerPool.Id)
)
)
.Build();
Adding effects
using UnityEngine;
using WorldTools.TutorialMaster.Core.Builders;
using WorldTools.TutorialMaster.Core.Builders.Effects;
using WorldTools.TutorialMaster.Core.Components;
using WorldTools.TutorialMaster.Core.Data;
using WorldTools.TutorialMaster.Core.Data.Effects;
using WorldTools.TutorialMaster.Core.Data.Markers.Pointer;
using WorldTools.TutorialMaster.Core.Data.Pooling;
using WorldTools.TutorialMaster.Core.Enums;
MarkerPool markerPool = m_TutorialMasterManager.MarkerPoolingSystem.Registry.FindByName("marker_pool_name");
Stage stage = new StageBuilder()
.AddEnterAction(chainBuilder => chainBuilder
.AddNext<ActionBuilders.SpawnPointerMarker>(spawnMarkerBuilder => spawnMarkerBuilder
.PointAt(PointDirection.Down)
.SetPositionByAnchors(Alignment.Top)
// add entrance effects
.SetEntranceEffects(builder => builder
.AddEffect<EffectBuilders.FlyIn>(effectBuilder => effectBuilder
.SetDistanceFromDestination(10)
.SetFlyInDirection(Direction.BottomRight)
.StartAfterPrevious()
)
.AddEffect<EffectBuilders.FadeIn>(effectBuilder => effectBuilder
.SetEffectDurationInSeconds(0.5f)
.StartAfterPrevious()
)
)
// add loop effects
.SetLoopEffects(builder => builder
.AddEffect<EffectBuilders.Float>(effectBuilder => effectBuilder
.SetOrientation(Orientation.Horizontal)
.SetFloatPattern(WaveType.Sine)
)
.AddEffect<EffectBuilders.ScalePulse>(effectBuilder => effectBuilder
.SetScaleRange(width: 20, height: 20)
)
)
.SetMarkerPool(markerPool.Id)
)
)
.Build();