Samples

The samples are small scenes that each show one part of Yarn Spinner for Unity, with the Yarn Scripts and C# that make them work. Open one, run it, then look at how it’s built.

The samples are a separate Unity package, Yarn Spinner Samples, in the YarnSpinner-Unity-Samples repository on GitHub. They aren’t part of the main Yarn Spinner package, so you add them to your project yourself.

Getting the samples

You need Yarn Spinner for Unity installed first. See Installation.

Then choose WindowYarn SpinnerInstall Samples Package. You can also click Samples at the top of the Inspector for a Dialogue Runner, a Yarn Project or a Yarn Script.

PLACEHOLDER — Screenshot needed
The Window menu open, with Yarn Spinner > Install Samples Package highlighted.

If you installed Yarn Spinner with the Package Manager, this adds the samples package from its Git URL, https://github.com/YarnSpinnerTool/YarnSpinner-Unity-Samples.git, and Unity installs it in the background. The samples are large, so it can take a little while. If you installed Yarn Spinner some other way, the menu item opens the installation instructions in your web browser instead.

Once the samples package is installed, the menu item is greyed out, and the Samples button in the Inspector opens the Package Manager at the samples package.

To add the package by hand, open WindowPackage Manager, click +, choose Install package from git URL, and enter https://github.com/YarnSpinnerTool/YarnSpinner-Unity-Samples.git.

Importing a sample

Installing the samples package doesn’t put any samples in your project. You import each one you want from the Package Manager:

  1. Open WindowPackage Manager.
  2. Select Yarn Spinner Samples. It’s listed under Packages - Yarn Spinner Pty Ltd, even if you got Yarn Spinner from the Asset Store.
  3. Open the Samples tab.
  4. Click Import next to the sample you want.
PLACEHOLDER — Screenshot needed
The Package Manager with Yarn Spinner Samples selected and its Samples tab open, showing the list of samples, each with an Import button.

Unity copies the sample into Assets/Samples/Yarn Spinner Samples/, in a folder named after the package version, then the sample.

If you can’t find the Samples tab, check that you’ve selected Yarn Spinner Samples under Packages - Yarn Spinner Pty Ltd, not under Packages - Asset Store. Where Unity shows the tab depends on your Unity version.

Running a sample

Each sample has a scene. Open it from the sample’s folder in the Project window, and press Play.

The samples were made with the Universal Render Pipeline. Most scenes have a Sample Renderer Detector GameObject, which logs a warning if your project doesn’t use a render pipeline, because the materials won’t look right. You can delete it.

What the samples share

Many samples use the same pieces, which come with the samples package in its Shared Assets folder:

  • The player and the other characters are prefabs, such as Player, NPC and Explanation Character, in Shared Assets/Prefabs. Capsley, the blue character who explains many of the samples, is an Explanation Character.
  • Shared Assets/Scripts has the scripts for moving characters around, following them with the camera, and letting the player talk to a character when they’re close to it. The Dialogue Interactable component starts a node on a Dialogue Runner when the player talks to the character it’s on.
  • Shared Assets/Art has the characters, environments, fonts and textures.

Most samples use the Dialogue System prefab from Yarn Spinner for its Dialogue Runner and Presenters. See Showing Dialogue.

In the 3D samples, move with W, A, S and D or the arrow keys. When you’re close enough to talk to a character, a speaking indicator appears over them. Press Space to talk to them. In a conversation, press Space, or click the button in the dialogue box, to show the whole line or go to the next one.

The samples

Getting started

Connecting to your game

Showing dialogue

Voice-over and localisation

Saliency and storylets

SampleFolder in the packageScene
WelcomeSamples~/WelcomeIntro
Feature TourSamples~/FeatureTourFeatureTour
Inline EventsSamples~/InlineEventsInline Events
Basic SaliencySamples~/BasicSaliencyBasicSaliencyDemo
Custom SaliencySamples~/CustomSaliencyCustom Saliency
Advanced SaliencySamples~/AdvancedSaliencyThe Room
Background ChatterSamples~/BackgroundChatterBackgroundChatter
Phone ChatSamples~/PhoneChatPhoneChat
Options That TimeoutSamples~/OptionsThatTimeoutTimeout
Replacement MarkupSamples~/ReplacementMarkupReplacement Markers
Themed Line PresenterSamples~/ThemedLinePresenterThemedLinePresenter
Node InternalsSamples~/NodeInternalsInternals
Voice OverSamples~/VoiceOverVoiceOver-BuiltInLocalization and VoiceOver-UnityLocalization
The samples, with where each one is in the samples package and the scene to open.

The Package Manager lists some samples under slightly different names: Theming Default Presenters is Themed Line Presenter, Voiceover and Localisation is Voice Over, and Basic Saliency and Storylets is Basic Saliency.

Get started Welcome A spoken introduction to the samples, with a custom Presenter that builds slides on a projector screen from lines of dialogue.