# Ink Narrative Integration The class already has a dialogue stack: the GameObject-and-JSON [[0.Dialogue System]], the modular [[Conversation Engine Design for Unity 6]], and the 360 spatial notes under [[Dialogue and Spaces 360 — Unity 6000.6.5f1 (Universal 3D URP)]]. Those are the right tools for short, scene-bound conversations you author next to an NPC. This series is for the other job: a **writer-first branching story** that grows past a handful of nodes. You will install **inkle's Ink** through the official Unity integration **2.0.0**, keep `.ink` files as the source of truth, drive a `Story` from C#, present lines and choices in **UI Toolkit**, hook variables and `EXTERNAL` functions into inventory and quests, and save the story state next to the rest of the save game. The design lens is [[Level Up! (Review)]] Level 3 ("Writing the Story"): Ink is the delivery vehicle for characters the player can care about, and for the beat chart of a conversation, not a substitute for having a story worth telling. Level 17 ("Cutscenes, or No One's Gonna Watch 'Em Anyway") still applies — keep forced text skippable, and never let a skip or a reload leave quest flags half-applied. The code lens is [[Game Programming Patterns (Review)]]: the compiled story JSON is **Bytecode** that a small VM (`Ink.Runtime.Story`) interprets; `ObserveVariable` is **Observer**; a choice the UI confirms is a **Command**; `story.state.ToJson` is a memento of the VM (not a chapter in Nystrom, but the same idea as a save blob); and the presenter is a **Component** that never owns the story rules. **Target:** Unity **6000.5+**. Package: **Ink Unity Integration `com.inkle.ink-unity-integration` 2.0.0** (released 2026-07-07; minimum Unity **2022.3 LTS**). UI is UI Toolkit (built into the engine). Input, where used, is **Input System `com.unity.inputsystem` 1.20.1**, the version the Unity 6000.5 package page lists as released for that Editor. Localization hooks refer to the built-in Localization package already covered in [[Localization]]. > [!warning] Code not compiled in Unity > No script in this series has been compiled or run **in the Unity Editor**, and nothing has been play-tested with the Ink Player window or in a Player build. > What *was* checked (2026-11-27): the Harbor Briefing `.ink` files were compiled with the **Ink compiler bundled in integration 2.0.0** (story format `inkVersionCurrent = 21`); all C# listings were extracted and type-checked with the Roslyn compiler shipped with Unity **6000.5.8f1**, against that Editor's `UnityEngine`/`UnityEditor` module assemblies, the **Ink 2.0.0** `Ink-Libraries` and `Ink` runtime assemblies built from the package source, Input System 1.20.0, and the Unity Test Framework / NUnit assemblies. Runtime and test assemblies built with **no errors**; the only warnings were CS0649 "never assigned" for `[SerializeField]` fields. The seven Harbor Briefing test cases were also **executed** against that compiled JSON and the 2.0.0 runtime, outside the Unity Test Runner, and all passed (polite path, wary leave, favour-at-trust-zero, second visit, `has_cleared`, save/load). Not checked: Editor import of `.ink` files, asmdefs in a real project, UXML/USS, inspector and Ink Player behaviour, Addressables, and anything at runtime in the Editor or a Player. Expect behavioural fixes rather than syntax ones. > [!note] Verification status (checked 2026-11-27) > **Verified from official docs or package source (integration 2.0.0 tag `a0b734d`, and inkle's `RunningYourInk.md`):** > - Install: Package Manager **Install package from git URL…** `https://github.com/inkle/ink-unity-integration.git#upm`, or OpenUPM scoped registry with `"com.inkle.ink-unity-integration": "2.0.0"`. The Asset Store `.unitypackage` is officially described as updated rarely and not recommended. > - Breaking 2.0 change: `.ink` files import as an `InkFile` ScriptableObject via a ScriptedImporter; **no sibling `.json` is generated**. Game code uses `new Story(inkFile.storyJson)` (`Ink.Runtime.Story`, `Ink.UnityIntegration.InkFile`). > - `InkFile` public surface (package source): `storyJson`, `isCompiled`, `isMaster`, `compileDate`, `errors` / `warnings` / `todos` / `unhandledCompileErrors`, and the `has*` helpers. > - Story API: `canContinue`, `Continue()`, `ContinueMaximally()`, `currentText`, `currentTags`, `currentChoices` (`Choice.text`, `Choice.index`, `Choice.tags`), `ChooseChoiceIndex`, `ChoosePathString`, `EvaluateFunction`, `HasFunction`, `variablesState[name]`, `ObserveVariable` / `ObserveVariables` / `RemoveVariableObserver`, `BindExternalFunction` (typed overloads, default `lookaheadSafe: false`) and `BindExternalFunctionGeneral` (default `lookaheadSafe: true`), `UnbindExternalFunction`, `ValidateExternalBindings`, `state.ToJson` / `state.LoadJson`, `SwitchFlow` / `RemoveFlow` / `SwitchToDefaultFlow`, `currentFlowName`, `onError`. > - Editor entry points from the 2.0.0 source: **Window > Ink Player** (`#i`, Ctrl/Cmd+Shift+I), **Assets > Create > Ink**, **Project Settings > Ink**, **Help > Ink**. > - The integration changelog last names an ink *language* bump in **1.3.0** (2026-07-05, "Updated Ink to 1.2.1"). **2.0.0** (two days later) does not announce a further compiler/runtime bump. The 2.0.0 package source sets `Story.inkVersionCurrent = 21`. > > **Not verified (flagged again where they matter):** whether a given Inky desktop build emits the same format version 21 as this package; Player-build failure behaviour when an `.ink` has compile errors under every CI path; `lookaheadSafe` interactions with glue in a story you have not written yet; Addressables and asset-bundle behaviour for `InkFile`; inspector wording on your exact Editor patch. ## Parts | # | Note | Covers | |---|---|---| | 1 | [[1. Ink vs the Dialogue System]] | When to keep the class Dialogue System, when to reach for Ink, how the two can share a UI, architecture map | | 2 | [[2. Installing Ink for Unity 2.0]] | Git and OpenUPM install, the `InkFile` importer, master vs INCLUDE, Ink Player, Project Settings, 1.x migration | | 3 | [[3. Ink Language Essentials]] | Knots, stitches, diverts, choices, gathers, variables, tags, INCLUDE, lists, and the Harbor Briefing story | | 4 | [[4. Story Loop and UI Toolkit Presenter]] | `InkStoryRunner`, line-by-line `Continue`, a UI Toolkit view, Input System advance, choice buttons | | 5 | [[5. Variables Tags and External Functions]] | Observers, tag conventions, `BindExternalFunction`, `EvaluateFunction`, `ChoosePathString` on interactables | | 6 | [[6. Saving Flows and Game System Hooks]] | `state.ToJson` next to the save game, flows, Localization, inventory and quest hooks, Timeline | | 7 | [[7. Worked Example Tests and Pitfalls]] | Harbor Briefing end to end, Edit Mode tests against compiled JSON, a symptom/cause/fix table | ## Project layout ``` Assets/InkNarrative/ Runtime/ InkNarrative.asmdef UI/ DialogueView.uxml, DialogueView.uss Stories/ HarborBriefing.ink, HarborItems.ink Tests/EditMode/ InkNarrative.Tests.asmdef ``` Everything lives in the `InkNarrative` namespace. The runtime assembly references the integration's `Ink` (for `InkFile`) and `Ink-Libraries` (for `Ink.Runtime.Story`) assemblies, plus the Input System. `Runtime/InkNarrative.asmdef`: ```json { "name": "InkNarrative", "rootNamespace": "InkNarrative", "references": [ "Ink", "Ink-Libraries", "Unity.InputSystem" ], "autoReferenced": true } ``` `Tests/EditMode/InkNarrative.Tests.asmdef`: ```json { "name": "InkNarrative.Tests", "rootNamespace": "InkNarrative.Tests", "references": [ "InkNarrative", "Ink-Libraries", "UnityEngine.TestRunner", "UnityEditor.TestRunner" ], "optionalUnityReferences": [ "TestAssemblies" ], "includePlatforms": [ "Editor" ], "overrideReferences": true, "precompiledReferences": [ "nunit.framework.dll" ], "autoReferenced": false } ``` The tests assembly references `Ink-Libraries` only, not `Ink`, so it can construct a `Story` from a JSON string without needing an imported `InkFile`. That is what lets Edit Mode tests run on the compiled story without the ScriptedImporter. ## Which existing note supplies what | Need | Existing note | |---|---| | Class Dialogue System (GameObject nodes, JSON, visual editor) | [[0.Dialogue System]], [[2.Dialogue System User Manual]], [[3.Dialogue System gameObject Nodes]], [[4.Dialogue System JSON file]], [[5.Dialogue System Dialogue Tree Editor]], [[7.Dialogue Visual Node Editor]] | | Modular conversation engine, presenter vs rules | [[Conversation Engine Design for Unity 6]] | | Spatial / 360 dialogue | [[Dialogue and Spaces 360 — Unity 6000.6.5f1 (Universal 3D URP)]], [[Setup guide — Dialogue and Spaces 360]] | | Packaging the class system as UPM | [[Authoring Custom UPM Packages]], [[3. Converting the Dialogue System into a Package]] | | UI Toolkit HUD, documents, styles | [[UI Toolkit and Diegetic UI]], [[2.UI Toolkit Project Setup]], [[3.HUD and Inventory Example]] | | Input actions and UI input | [[Input System]] | | Subtitles on a Timeline track | [[Timeline Advanced]], [[3. Subtitle and Dialogue Track]] | | String tables, dialogue localization, pseudo-localization | [[Localization]], [[6. Localizing Game Data Dialogue and Pseudo-Localization]] | | Inventory grants from `EXTERNAL` functions | [[Inventory Systems]] | | Quest stage changes from the story | [[Quest Systems]] | | Save slots the story JSON should live in | [[High Scores, Saves and Player Stats]] | | Event channels and data assets | [[ScriptableObject Architecture]] | | Tests and test assemblies | [[Unity Test Framework]] | | Writing, characters, skippable cutscenes | [[Level Up! (Review)]] | | Bytecode, Observer, Command, State | [[Game Programming Patterns (Review)]] | ## Architecture ```text Authoring Runtime Scene ───────── ─────── ───── HarborBriefing.ink ─┐ Ink.Runtime.Story InkStoryRunner (owns the Story) HarborItems.ink ───┤ Scripted variablesState InkGameBindings (EXTERNAL → inventory, audio, quests) │ Importer state.ToJson / LoadJson InkDialogueView (UI Toolkit) └─ InkFile currentText / currentChoices InkInteractable (ChoosePathString) .storyJson currentTags save blob next to the game save ``` - **The `.ink` file is the source of truth.** Unity compiles it on import into an `InkFile`. You never hand-edit the compiled JSON. - **The `Story` is the rules.** The runner advances it and raises events. The view renders the last line and the current choices. Bindings apply side effects. None of those three owns the others' data. - **Side effects go through `EXTERNAL` functions and observers**, not by scraping the current text. If a grant must survive a skip or a reload, it must also be represented in `variablesState` or in your own save data. Next: [[1. Ink vs the Dialogue System]]. ## In this folder <!-- folder-list:start --> <!-- generated by pubprojects_weblists.py: edits inside this region are replaced on the next run --> *No notes in this folder are published yet.* <!-- folder-list:end --> See also: [[Facial Animation and Lip Sync]] - faces driven by #speaker, #mood and #voice tags: expressions, blinks, gaze and lip sync. See also: [[Narrative Vertical Slice Capstone]] (Ink with cutscenes, dialogue cameras, faces and two endings in one slice).