Skip to main content

Setup the UI

In the Hierarchy, right-click and create UI Document with “UI Toolkit/UI Document”. Select it, and choose “UIToolKitBasePanel” for the Panel Settings field, and “UIToolKitBase” for the Source Asset field. These two come prepackaged with Parley to make things easier for you to get started.

Writing the Dialogue

Create a folder at Resources/English/Emotions/Create the following file inside it:
en.Example.yaml

Setting up the Script

With the file ready, let’s get into the script.Create a C# script and name it something like YamlEmotionsUIToolKit.cs and write the following.
YamlEmotionsUIToolKit.cs

Wiring things up

Back in the unity editor, add that script to the UI Document object we made earlier in the UI section, and click on the “Add Component” button and add a “UI ToolKit Handler” script, this also comes with Parley to handle all the functions we use to set UITK scenes.Assign the UI Document field in the UI ToolKit Handler component to the UI Document component above it.In the Graph Emotions UI ToolKit script, set the UI Took Kit Handler component to the UI ToolKit Handler component we added earlier. And create 4 sprite entries with the exact same emotions in the file, and assign each sprite.You should be left with something like this:Script Variable Fields

Testing

Hit play. Left click in the Game View to advance through the dialogue — you should see the speaker and text update with each click, the sprite gets set, and the dialogue ends cleanly on the last node.