Yarn Spinner for Unreal Engine Editor Tools

Yarn Spinner adds two asset types and a few menu items to the Content Browser, headers and a node picker to the Details panel, and two pages in Project Settings. For finding problems while the game runs, it has a Debug HUD component and verbose logging.

In the Content Browser

Yarn Spinner adds two asset types. Both are under Miscellaneous in the Content Browser’s filters.

Asset typeMade fromWhat it’s for
Yarn ProjectA .yarnproject fileThe compiled dialogue a Dialogue Runner runs. See Yarn Projects.
Yarn Source FileA .yarn fileA copy of a script’s text, to look at in Unreal. You don’t need these. See Yarn Source File assets.
The asset types Yarn Spinner adds.

Each has its own thumbnail in the Content Browser:

The Yarn Project icon A Yarn Project's thumbnail.
The Yarn Source File icon A Yarn Source File's thumbnail.
The thumbnails for the two asset types.

Right-click a Yarn Project for these menu items:

Menu itemWhat it does
ReimportCompiles the .yarnproject file again, and updates the Yarn Project. You only need this when Yarn Spinner hasn’t noticed a change. See Changing a script.
Generate YSLS FileRewrites the project’s .ysls.json file, for autocomplete in VS Code. See The .ysls.json file.
The menu items Yarn Spinner adds for a Yarn Project.

A Yarn Source File has Reimport too, which reads the .yarn file again.

The Yarn Spinner components have their own icons in the Components panel and the Add menu, so you can tell a Dialogue Runner from a Presenter.

In the Details panel

Yarn Spinner adds to the Details panel for a few kinds of object:

  • Dialogue Runner, Dialogue Presenters and Yarn Input Handler: the Yarn Spinner section has a header with the Yarn Spinner logo, the version of the plugin, and links to the documentation and to support on Discord. This includes every Presenter, such as the Line Presenter, the Options Presenter and the Line Advancer.
  • Yarn Node Reference: anywhere you use one, it shows a Yarn Project picker, and a dropdown of that project’s nodes in place of a text box.
  • Yarn Projects and Yarn Source Files: double-clicking one shows what was imported. See The Yarn Project asset.
The Yarn Spinner header on a Dialogue Runner in the Details panel, with the version 3.2.8-alpha9 and Docs and Support links, above Yarn Project, Variable Storage, Dialogue Presenters, Line Provider and Asset Provider, all empty.
The Yarn Spinner header on a Dialogue Runner.

Picking a node from a list

A Yarn Node Reference is a Yarn Project and a node name together. Add a variable of this type to a Blueprint, or a UPROPERTY of type FYarnNodeReference in C++, and you pick the node from a dropdown, so you can’t mistype its name. If the node isn’t in the project, its tooltip says so.

Pass it to the Dialogue Runner’s Start Dialogue From Reference to start from that node. Is Node Reference Valid tells you whether the project contains the node.

The Dialogue Runner’s own Start Node is a text box, not a dropdown.

The Dialogue Runner’s settings, such as Dialogue Presenters, Variable Storage and Auto Start, are explained in Dialogue Runner.

Project settings

Yarn Spinner adds two pages to EditProject Settings, under Plugins.

Yarn Spinner

SettingDefaultWhat it does
Ysc PathemptyWhere to find ysc, the Yarn Spinner compiler. Leave it empty and Yarn Spinner looks in the usual install locations and on your PATH. See Compiling.
Yarn Spinner’s settings in Project Settings.

Ysc Path is saved for you only, in your project’s Saved folder, not in its Config folder. Everyone on your team can install ysc in a different place.

Yarn Spinner Command Registry

This page lists the Commands and Functions Yarn Spinner found in your C++ code: UFUNCTIONs marked with YarnCommand or YarnFunction. Each entry has the name your Yarn Scripts use, the class and the function. You can’t edit it. The editor updates it whenever it writes your .ysls.json files.

It’s saved in Config/DefaultGame.ini, and packaged builds use it to find these Commands and Functions. Commit it to source control with the rest of your project. If Unreal can’t write to the file, for example because it’s read-only, the Output Log shows a warning, and packaged builds may miss some Commands. See The .ysls.json file.

The Debug HUD

The Yarn Debug HUD component keeps track of what a Dialogue Runner is doing while the game runs: whether dialogue is running, the current node, the current line, your variables, and a history of what’s happened. Press a key to show or hide it on screen.

BP_Rosa (Self)
DefaultSceneRoot Scene Component
YarnDialogueRunner Yarn Dialogue Runner
YarnLinePresenter Yarn Line Presenter
YarnOptionsPresenter Yarn Options Presenter
YarnLineAdvancer Yarn Line Advancer
YarnDebugHUD Yarn Debug HUD Component
An Actor with a Debug HUD next to its Dialogue Runner.

To set it up:

  1. Add a Yarn Debug HUD component to the Actor that has your Dialogue Runner. It finds the Dialogue Runner on the same Actor. To watch a Dialogue Runner on a different Actor, set Dialogue Runner.
  2. Make a Widget Blueprint whose parent class is Yarn Debug Widget. Lay out the information you want, using the widget’s Current Node Name, Current Line ID and Is Dialogue Running variables, and its Get Formatted Variables and Get History functions. The widget updates them ten times a second. The variables come from Yarn Debug Widget, so the My Blueprint panel only lists them after you click its gear icon and turn on Show Inherited Variables. Get Formatted Variables returns a list with one entry for each variable, like $gold = 5.00. To show them in one Text Block, join them with Join String Array. The list only has your variables when the Dialogue Runner uses the Yarn In Memory Variable Storage.
  3. On the Debug HUD component, set Debug Widget Class to your Widget Blueprint.
  4. Play, and press F3.
WBP_YarnDebug in the Designer. The Hierarchy shows a Canvas Panel with a Vertical Box holding three Text Blocks, NodeName, LineID and Variables, and the canvas shows them at the top left.
A debug widget with Text Blocks for the node, the line ID and the variables.
Yarn Debug Widget has no layout of its own. If you leave Debug Widget Class empty, the Debug HUD still keeps track of everything, but nothing appears on screen.

The component’s settings, under Yarn Spinner > Debug in the Details panel, are:

SettingDefaultWhat it does
Dialogue RunneremptyThe Dialogue Runner to watch. If it’s empty, the component uses the Dialogue Runner on its own Actor.
Debug Widget ClassemptyThe widget to show. Set it to a Widget Blueprint based on Yarn Debug Widget.
Toggle KeyF3The key that shows and hides the HUD.
Show By DefaultOffShows the HUD as soon as the game starts.
Auto Log EventsOnAdds an entry to the history when dialogue starts and ends, and when each node starts and ends.
Screen Anchor0, 0Meant to set where the HUD appears. In this version, it has no effect, so position things in your widget instead.
The Yarn Debug HUD component’s settings.

The history only records lines, chosen options and Commands if you tell it to. Call Log Line, Log Option Selected and Log Command on the component, for example from your own Presenter or Command handlers. Log Node Start and Log Node End add node entries yourself, if you’ve turned off Auto Log Events. The widget keeps the 100 most recent entries. Change its Max History Entries to keep more or fewer.

Get Formatted Variables lists every variable as text, like $gold = 10.00. It only works when the Dialogue Runner’s Variable Storage is a Yarn In Memory Variable Storage, which is the default.

You can also show and hide the HUD from Blueprints or C++, with Show Debug HUD, Hide Debug HUD, Toggle Debug HUD and Is Debug HUD Visible.

The Debug HUD never appears in a Shipping build, so you can leave the component on your Actors.

Verbose logging

For more detail, turn on Verbose Logging on the Dialogue Runner, under Yarn Spinner > Debug. The Dialogue Runner then writes a line to the Output Log, from LogYarnSpinner, when each node starts and finishes, for each Command it runs, each time it shows options, and when the dialogue ends.

Next step Showing Dialogue The Dialogue Runner, the built-in Presenters, and getting your dialogue on screen.