Unreal Engine integration
This page is a deep dive into using the exported Unreal plugin once it's compiled — the "no-code" Blueprint workflow. For the export step itself (what gets generated, first-time install, and the C++ API), see Game engine export → Unreal Engine. For release/test validation, use the Unreal export/import test manual.
Verified against UE 5.7
The generated plugin has been build-tested end to end (Editor + Game targets, Development + Shipping) against Unreal Engine 5.7.
The exported structure
Exporting to Unreal (left sidebar → Export to game engine → Unreal) writes a self-contained <Project>_Unreal/ folder next to your YarnDraft project:
<Project>_Unreal/
├── Plugins/
│ └── YarnDraft/
│ ├── YarnDraft.uplugin
│ ├── Source/YarnDraftRuntime/ ← C++ runtime module (story player, entity data asset)
│ ├── Source/YarnDraftEditor/ ← editor-only module (entity importer, Live Sync, toolbar)
│ └── Content/
│ ├── BP_YarnDraftPlayer.uasset ← Blueprint Actor wrapper
│ ├── BPC_YarnDraft.uasset ← Blueprint Actor Component wrapper
│ ├── WBP_YarnDraftDialogue.uasset
│ └── WBP_YarnDraftChoiceButton.uasset
├── Content/
│ └── YarnDraft/
│ ├── story.json ← the exported, sanitized story graph
│ └── assets/ ← referenced .wav / .mp3 / .ogg audio files
└── Config/
└── Tags/
└── YarnDraftTags.ini ← every unique Gameplay Tag used by your entitiesPlugins/YarnDraftis a code plugin — it ships C++ source, not prebuilt binaries, so Unreal compiles it as part of your project.Content/YarnDraftholds your story data —story.jsonplus any audio actually referenced by a Dialogue or Audio card. Live Sync refreshesstory.jsonand copies referenced audio files intoContent/YarnDraft/assets/.Config/Tags/YarnDraftTags.inilists every Gameplay Tag referenced by agameplayTagListentity field, in the standardGameplayTagsListformat Unreal expects. Live Sync/import can refresh this file fromstory.json, but newly added tags still require an Unreal Editor restart before the Gameplay Tags manager sees them.
How to install
- Copy the folders in. Merge
Plugins/YarnDraft/,Content/YarnDraft/, andConfig/Tags/YarnDraftTags.iniinto your Unreal project's root, next to your own.uproject,Plugins/,Content/, andConfig/folders — don't overwrite your existing folders, just drop the YarnDraft subfolders/files into each. - Open or convert the project for C++. First double-click the
.uprojectand accept Unreal's missing-module rebuild prompt. If project-file generation says the project has no source code, open the project in Unreal Editor, create one empty C++ class (Tools → New C++ Class), close the editor, then right-click the.uproject→ Generate Visual Studio project files (Windows) or generate Xcode project files (Mac). - Compile the module — open the generated solution and build (Development Editor config), or reopen the
.uprojectand accept Unreal's rebuild prompt. - Open the project and check Edit → Plugins → search "YarnDraft" to confirm it's enabled (project plugins are on by default — this is just a sanity check).
C++ toolchain required
Unreal always compiles code plugins from source, so you'll need Visual Studio with the "Game development with C++" workload (or Xcode on Mac) installed, even if your project has never had any other C++ code.
You only need to repeat steps 2–4 once per project. Later story-only re-exports just need the new Content/YarnDraft/story.json dropped in — no recompiling.
How to use it — the "no-code" way
Both BP_YarnDraftPlayer and BPC_YarnDraft live inside the plugin's own Content folder, which the Content Browser hides by default.
Show Plugin Content
In the Content Browser, open the Settings (gear icon, bottom-right) and enable Show Plugin Content. A new YarnDraft Content folder then appears in the Content Browser, containing BP_YarnDraftPlayer and BPC_YarnDraft.
Both Blueprints are meant as a starting point, not as a finished dialogue UI:
Story File Name— on the YarnDraft dialogue component, a string selector populated fromContent/YarnDraft/**/*.jsonfiles. The default isYarnDraft/story.json.Start Flow Name— on the YarnDraft dialogue component, an optional flow selector. Leave it empty for the root flow, or choose a flow name from the dropdown populated from the selected story file.Dialogue Widget Class— use the plugin-providedWBP_YarnDraftDialoguefor a simple textbox + choice-button UI, or replace it with your own widget derived fromUYarnDraftDialogueWidget.OnLine/OnChoicesevents drive the widget. Plain lines advance withAdvance(), choices callChoose(Index).OnGameEventis available on theYarnDraft Dialoguecomponent for Game Event cards. Bind it in Blueprint when you want a node such asopen_doorto trigger game logic.OnInventoryChangedfires when an Inventory card gives or takes an item. Use theEntityIdand currentQuantityto update your own inventory/journal UI. UseGetInventoryQuantity(EntityId)when a Blueprint needs the current count on demand.ExportStateJson()/ImportStateJson(Json)save and restore YarnDraft variables, tasks, clues, and inventory counts for your game's SaveGame object. They do not save the current textbox or selected choice UI position.- If keyboard input does not reach the actor, set Auto Receive Input to
Player 0or callEnable InputfromBeginPlay. - For a custom UI, bind line text to a Text widget, build dynamic buttons from choices, hide the choice panel during plain lines, and show it only when choices are present.
Method A — the Blueprint Actor (BP_YarnDraftPlayer)
The simplest way to try a story in-level, with no scripting at all:
- Drag
BP_YarnDraftPlayerfrom the YarnDraft Content folder into your level. - Select the placed actor and, in the Details panel, find Story File Name — change it if your story file isn't named
story.json(e.g. if you export multiple stories side by side). - Press Play. The actor loads the story on
BeginPlayand shows the first line/choices through the default widget. If input does not advance, give the actor input focus as described above or callAdvance()from your own UI/input event.
Good for quick playtesting
This is the fastest way to sanity-check a fresh export in-engine before wiring any real UI — drop it in an empty test level and press Play.
Method B — the Actor Component (BPC_YarnDraft)
To drive the story from your existing player character (or any other actor) instead of a standalone actor:
- Open your player character's Blueprint.
- Add Component → search BPC_YarnDraft → add it.
- Select the component and set its Story File Name in the Details panel, same as Method A.
- The component loads the story and exposes the same line, choice, task, clue, and game-event hooks. Use the default widget for smoke tests, then replace it with your actual game UI when needed.
Game Event cards in Blueprint
To react to a YarnDraft Game Event card:
- In your actor Blueprint, drag the
YarnDraft Dialoguecomponent into the graph. - From it, add
Bind Event to On Game Event. - Run that bind once from
BeginPlay. - Create a matching custom event, for example
HandleGameEvent. - Use the
Eventstring to switch on names such asopen_door. - Break
ParamswithBreak Yarn Draft Trigger Params; read values from theValuesmap withFind, for example keydoorId.
If YarnDraft has Event Name = open_door and doorId = test_door_01, Blueprint receives:
Event: open_door
doorId: test_door_01Audio cards in Blueprint
Audio cards emit data; they do not play sound by themselves. To react in Blueprint:
- Drag the
YarnDraft Dialoguecomponent into the graph. - Add
Bind Event to On Audio Cuefrom that component. - Run the bind once from
BeginPlay. - Create a matching custom event, for example
HandleAudioCue. - Break the cue and use
AudioType,AssetPath,Volume, andFadeSecondsto drive your own audio playback.
For a smoke test, print AudioType and AssetPath first. Wire real playback only after those values appear.
When to pick which method
Use Method A for a dedicated "story manager" actor per level, or Method B when the narrative should live and travel with a specific actor (e.g. the player pawn, or an NPC that only talks once triggered).
Beyond the Blueprint wrappers
For full control — custom save/load timing, multiple concurrent stories, or driving the player from C++ — construct UYarnDraftStoryPlayer directly instead of using either Blueprint wrapper. See Game engine export → Use it for the C++ snippet and the full delegate list (OnLine, OnChoices, OnTrigger, OnAudioCue, OnChoiceVoice, OnTaskChanged, OnClueDiscovered, OnFinished).
Entity Data Assets & Gameplay Tags
The editor module also turns your YarnDraft Entities into native UPrimaryDataAsset Data Assets, and can auto-populate registered Gameplay Tags — see Game engine export → Entity Data Assets for the importer workflow (Tools → Import YarnDraft Entity Data Assets, or the Live Sync toolbar button).
