# Tutorials

**URL:** https://heroiclabs.com/docs/hiro/unity/tutorials/
**Keywords:** tutorials, hiro
**Categories:** hiro, unity, tutorials

---


# Tutorials

Read more about the Tutorials system in Hiro [here](../../concepts/tutorials/).

## Initializing the tutorials system

The tutorials system relies on the [Nakama System](../getting-started/nakama-system) and an `ILogger`, both must be passed in as dependencies via the constructor.

```csharp
var tutorialsSystem = new TutorialsSystem(logger, nakamaSystem);
systems.Add(tutorialsSystem);
```

## Subscribing to changes in the tutorials system

You can listen for changes in the tutorials system so that you can respond appropriately, such as updating the UI, by implementing the `IObserver` pattern, or use the `SystemObserver<T>` type which handles it for you.

```csharp
var disposer = SystemObserver<TutorialsSystem>.Create(tutorialsSystem, system => {
    Instance.Logger.Info($"System updated.");

    // Update UI elements etc as necessary here...
});
```

## Refreshing the tutorials system

To ensure the tutorials system has the latest information from Nakama you can refresh it.

```csharp
await tutorialsSystem.RefreshAsync();
```

## Getting all tutorials

You can get all tutorials.

```csharp
var tutorials = tutorialsSystem.GetAllTutorials();
foreach (var tutorial in tutorials)
{
    Debug.Log($"Tutorial {tutorial.Id}");
    Debug.Log($"Step {tutorial.Current} of {tutorial.Max}");

    if (tutorial.State == TutorialState.Completed)
    {
        var completedAt = DateTimeOffset.FromUnixTimeMilliseconds(tutorial.CompleteTimeSec).DateTime;
        Debug.Log($"Completed at {completedAt.ToShortDateString()}");
    }
}
```

## Get an individual tutorial

You can get an individual tutorial.

```csharp
var tutorial = tutorialsSystem.GetTutorial("<tutorialId>");
```

## Accepting a tutorial

You can accept an offered tutorial.

```csharp
await tutorialsSystem.AcceptTutorialAsync("<tutorialId>");
```

## Declining a tutorial

You can decline an offered tutorial.

```csharp
await tutorialsSystem.DeclineTutorialAsync("<tutorialId>");
```

## Abandoning a tutorial

You can abandon a tutorial.

```csharp
await tutorialsSystem.AbandonTutorialAsync("<tutorialId>");
```

## Updating a tutorial

You can update the current step of a tutorial.

```csharp
await tutorialSystem.UpdateTutorialAsync("<tutorialId>", 3);
```

## Additional information

- [Mage Mayhem sample project](../../../../sample-projects/games/mage-mayhem)
