API Reference
Every public class, method, and event in the Poetix SDK for Unity.
Everything your scripts can use from the Poetix SDK. Most games only need Poetix, a static class that works from any script with using PoetixSDK; and no setup. The guides explain how the pieces fit together.
I want to…#
All classes#
Start here
Helpers for your own UI
Start here#
Most game code only needs Poetix. It talks to the scene’s Dialogue Manager for you, so there is nothing to set up.
Poetix
static classusing PoetixSDK;
The one place game code talks to Poetix: start and stop conversations, read and change variables, block dialogue input, read the history, and save. It works the same with the Dialogue Box and with your own UI.
Guide: Controlling Dialogue from Code
Conversations
Starts a conversation from a beat, by its name in Poetix, or from the story’s root beat when none is given. Pass a StoryAsset to play another story. Returns false and does nothing while a conversation is playing, unless restart is true.
True while a conversation is playing. Check it to freeze your player during dialogue.
Fired when a conversation starts and when it ends. Subscribe in OnEnable and unsubscribe in OnDisable.
Variables
Reads a story variable by its name on the blackboard, ignoring case. Read Numbers as int, float or double, Booleans as bool, and Strings as string. Returns defaultValue when the story has no such variable.
Changes a story variable. The value is converted to the variable’s type. An unknown name, or a value that can’t be converted, is logged as an error and changes nothing.
Calls onChange(before, after) whenever the variable changes, however it changed: the story, SetVar, loading, resetting, or a new scene. callNow also calls it once right away. Stops by itself when the object it belongs to is destroyed; pass owner: this if the callback uses local variables, or call Dispose() on the result to stop earlier.
Your own dialogue UI
Fired with each line to show: its condition passed, its results are applied, and its {{variables}} are filled in. Call Continue when the player moves on.
Fired right after the last line of a beat that has choices, in the same frame. Each choice says whether its condition passed (ConditionEval.Result). Call Choose with the one the player picks.
Fired when the player picks a choice, before its results are applied. Choices picked by auto-choice beats don’t fire it.
Moves on from the line being shown. Does nothing while choices are waiting, and in the frame the line appeared, so one key press handled by two scripts moves on only once. When every choice failed its condition, it ends the conversation.
Picks a choice. By index, 0 is the first choice the player can pick, in number-key order; choices whose condition failed aren’t counted and can’t be picked. Ignored in the frame the choices appeared.
What is on screen right now: the line (null when no conversation is playing) and the choices waiting (empty while a line is showing). Use them to catch up when your UI is turned on mid-conversation.
Input
Makes dialogue ignore keys and clicks while your menu is open. Each owner blocks separately, so input returns when the last one unblocks. A destroyed owner stops blocking by itself.
True while dialogue ignores the player’s keys and clicks: something blocked it, or the player is typing in a text field.
History
The lines shown and choices picked so far, oldest first, up to the Dialogue Manager’s History Size. For a backlog or journal screen.
Fired when a line or picked choice is added to History.
Saving
The story state as text, to store with your save game: every story’s variables and, during a conversation, the line being shown. Poetix doesn’t write files.
Restores text from SaveState. A save made during a conversation reopens it at the saved line. Saves made before a story update still load.
Ends any conversation and sets every variable of every story back to its starting value, for a new game.
DialogueState
static classusing PoetixSDK;
Whether any conversation is playing, in any Dialogue Manager. Poetix.IsPlaying, Poetix.Started and Poetix.Ended read from here, so most code uses those instead.
Members
True while any Dialogue Manager is playing a conversation.
Fired when any Dialogue Manager starts or ends a conversation. Ended also fires when the manager playing one is destroyed. A restart with restart: true fires Started again without Ended in between.
DialogueInput
static classusing PoetixSDK;
Whether dialogue should ignore input right now. Poetix.BlockInput and Poetix.IsInputBlocked cover the usual needs.
Members
Same as Poetix.BlockInput and Poetix.UnblockInput. Blocking twice with one owner needs only one unblock.
True while something blocks input or the player is typing in a text field.
True while at least one owner has blocked input and not unblocked it.
True while a UI text field (TextMesh Pro or legacy) or a Poetix overlay such as the Debug Menu has keyboard focus.
True while the pointer is over the Debug Menu, so a click there doesn’t advance the dialogue.
Components#
The parts you add to a scene. Everything you set in their Inspector can also be set from code.
DialogueStarter
componentusing PoetixSDK;
Remembers which story and beat an object starts, and what starts it: the interact key in range, a click, the player walking in, or your own call to Play.
Guide: Starting Dialogues Without Code
Starting
Starts this object’s conversation. Does nothing while any conversation is playing, or when PlayOnce is on and it already played. Call it from your own interaction code, a UI button, or a Timeline signal.
Settings
The story this object starts. Null uses the Dialogue Manager’s story.
Inspector: Story
The beat the conversation begins with. Empty starts from the story’s root beat.
Inspector: Start From
What starts the conversation: StartMode.Manually, WhenPlayerEnters, InteractKeyInRange, or WhenClicked.
Inspector: Start On
With WhenClicked, clicks only count while the player is in range. Turn off for point-and-click games.
Inspector: Only in Range
Start the conversation only the first time.
Inspector: Play Once
Whether the conversation has started at least once. With PlayOnce, set it back to false to allow another play, for example after loading a save made before it played. It isn’t saved by Poetix.SaveState.
An object shown while the conversation can start, such as an “[E] Talk” label.
Inspector: Prompt
The Dialogue Manager that plays the conversation. Null uses the scene’s.
Inspector: Advanced > Dialogue Manager
State
True while the player is inside this object’s trigger. Always false in Manually.
True while the mouse is over the character and a click would start the conversation (WhenClicked).
Events
The player comes into or leaves range. The …Event versions are the Inspector’s UnityEvents, so you can add listeners from code too.
Inspector: Events > On Player Entered / On Player Exited
With WhenClicked: the mouse moves over the character while a click would start the conversation, and leaves again. For your own highlight or cursor.
Inspector: Events > On Pointer Entered / On Pointer Exited
This object’s conversation begins or ends.
Inspector: Events > On Dialogue Started / On Dialogue Ended
DialogueBox
componentusing PoetixSDK.UI;
The ready-made dialogue UI. Each property matches a setting in its Inspector, so you can change them for one scene or moment, like turning on auto-advance during a cutscene.
Guide: The Dialogue Box
Finding it
The Dialogue Box in the scene, or null when there is none.
Theme and layout
The theme, applied right away when set. Null shows the box’s plain look. Switching never leaves styling from the previous theme behind.
Inspector: Theme
The theme actually shown: ActiveTheme, or Modern Minimal when that theme’s asset is missing. Null only when no theme was chosen on purpose.
Switches to a layout preset.
Inspector: Layout > Preset
The layout’s settings: preset, boxPosition, boxWidth, boxHeight, choices, portrait, name, lineAlignment and showPanel. After changing them, call RefreshLayout.
Inspector: Layout
Text and pacing
Type lines out letter by letter. When false, each line appears in full.
Inspector: Text & Pacing > Text Reveal
Seconds per letter while typing (0.025 by default). Lower is faster.
Inspector: Text & Pacing > Speed
Extra seconds after , ; : — and after . ! ? while typing. 0 for no pause.
Inspector: Text & Pacing > Pause After Commas / Pause After Sentences
Lines move on by themselves after AutoAdvanceDelay seconds plus AutoAdvancePerCharacter per letter (1 and 0.05 by default). Choices still wait for the player.
Inspector: Text & Pacing > Auto Advance, Wait After Line, Per Letter
Holding a fast-forward key skips through lines, each shown for FastForwardLineDelay seconds, and always stops at the next choice.
Inspector: Text & Pacing > Fast Forward, Time per Line
Keys
Which keys show the next line, or the rest of the line being typed. All on except E, which the Dialogue Starter uses.
Inspector: Input & Choices > Advance
Which keys fast-forward while held: Ctrl, Tab, and the gamepad’s right shoulder button.
Inspector: Input & Choices > Fast Forward
Which keys pick the highlighted choice, and whether number keys 1–9 pick a choice by its number. Clicking a choice always works.
Inspector: Input & Choices > Pick Choice
The name of the key that continues, as the theme’s key hint shows it. Empty when only clicking continues.
Choices
How choices whose condition failed are shown: Hidden (the default), GreyedOut, or GreyedOutWithLock.
Inspector: Input & Choices > Locked Choices
Highlight the first choice when choices appear. When false, the first press of a pick key highlights it instead of picking it.
Inspector: Input & Choices > Highlight First Choice
Seconds choices ignore input after appearing (0.25 by default), so a player tapping through lines doesn’t pick one by accident.
Inspector: Input & Choices > Choice Input Delay
While testing, show every locked choice with the condition it failed. Only takes effect in the editor and Development builds; AreFailedConditionsShown says whether it is in effect now.
Inspector: Debugging > Show Failed Conditions
Portraits and names
Pick the portrait shown for a character, for example a silhouette until the player has met them. Called with the character’s ID for every line; return null for the usual portrait. Pass null to remove it.
Pick the name shown for a character, for example “???” until the player has met them. Return null for the story’s name, or an empty string for no name plate. Pass null to remove it.
The portrait used for characters that have none of their own, shown right away.
A character’s portrait from the story being played, or null when it has none.
Sound and time
The box’s sound settings and hooks. See DialogueAudioConfig.
Inspector: Audio
Play the theme’s typing sound while a line types, once every N letters (spaces skipped).
Inspector: Audio > Typing Sound, Every N Letters
When true, typing, auto-advance and fast-forward wait while Time.timeScale is 0. When false (the default), dialogue keeps running in a paused game.
Inspector: Advanced > Pause With Game Time
Player settings
Text size of every Dialogue Box, from 0.75 to 2, where 1 is the theme’s size. Offer it in your options menu.
Turns off the theme’s animations (opening, closing, choices appearing, the continue prompt, highlight growth) in every Dialogue Box.
Fired when TextScale or ReduceMotion changes.
Rarely needed
What an advance key does: shows the rest of a line being typed, or moves on. Prefer Poetix.Continue unless you want the typing behavior.
Shows the rest of the line being typed, and its choices if it has any.
Picks one of the choices the box is showing, 0 being the first pickable one. Poetix.Choose does the same for any UI.
Ends the conversation and closes the box. Same as Poetix.Stop.
Apply or remove a theme. Setting ActiveTheme does the same.
DialogueAudioConfig
classusing PoetixSDK.UI.Audio;
The Dialogue Box’s sound settings, from DialogueBox.AudioConfig. The sounds themselves come from the theme. Using FMOD, Wwise, or your own audio code? Set a CustomPlay… hook and the box calls it instead of playing the theme’s sound.
Settings
Volume of all dialogue sounds, 0 to 1. Each sound’s own volume is set in the theme.
Inspector: Audio > Volume
The Audio Mixer group dialogue sounds play through, such as your SFX group.
Inspector: Audio > Output
The Audio Source the sounds play from. When none is set, the box adds a hidden 2D one. Set your own for 3D sound or effects.
Your own audio
Called instead of the theme’s sound when the box opens, closes, moves to the next line, highlights or picks a choice, and types a letter. Set one back to null to use the theme’s sound again.
Rarely needed
Play one of the dialogue sounds now, or its custom hook when one is set.
Used by the Dialogue Box to set up its sounds. You don’t need to call them.
DialogueManager
componentusing PoetixSDK;
Plays a story. Every Dialogue Box has one, and you can add one alone for your own UI. Most code uses Poetix, which calls the scene’s manager. Use a manager directly for scenes with several managers playing at once, or for its detailed events.
Guide: Building Your Own Dialogue UI
Finding it
The scene’s Dialogue Manager, the one Poetix talks to.
Settings
The story it plays. A change takes effect at the next conversation.
Inspector: Story
Start a conversation as soon as the scene loads, from this beat (empty for the root beat).
Inspector: Play When Scene Starts, Start From
Keep this object, and its Dialogue Box, when a new scene loads.
Inspector: Advanced > Keep Between Scenes
How many past lines and picked choices the history keeps (100 by default).
Inspector: Advanced > History Size
Stop the conversation at the first story error while testing in the editor. Builds never do; IsStrict says whether it is in effect.
Inspector: Debugging > Stop on Story Errors
Same as Poetix
This manager’s Poetix.Play, Poetix.Stop and whether it is playing.
Move on or pick a choice (by its Id), and what is on screen now. Unlike Poetix.Continue and Poetix.Choose, these aren’t ignored in the frame the line appeared.
Read and change variables of this manager’s story, by name or ID.
This manager’s history, and emptying it.
Poetix.SaveState, LoadState and ResetState.
Events
This manager’s conversation begins or ends.
Inspector: Events > On Dialogue Started / On Dialogue Ended
A line is ready to show. The UnityEvent passes only its text.
Inspector: Events > On Line Shown
Choices are waiting for the player.
The player picked a choice, before its results apply. The UnityEvent passes its text.
Inspector: Events > On Choice Picked
Any variable of this manager’s story changed. Poetix.WatchVar is simpler for one variable.
A line or picked choice was added to the history.
Rarely needed
A character’s name from the story, ready to show. Lines already carry it as SimLine.SpeakerName.
Reset only this story’s variables, keeping the conversation playing; or forget every story’s variables. Poetix.ResetState is the usual “new game”.
Every variable with its current value, as the Debug Menu shows them.
What the story does step by step, as the Debug Menu’s Log shows it: conditions checked, lines shown and skipped, variables changed, and warnings. For your own debugging tools.
The plain C# engine playing the story, and the parsed story. For tools that need the story’s raw data.
StoryAsset
assetusing PoetixSDK;
A .poetix story in your project. Reference one in a field to play it with Poetix.Play(story, beat) or to find its portraits.
Guide: Importing & Syncing Stories
Members
A character’s portrait, or null when it has none. Pass a line’s CharacterId.
Every character’s portrait in this story.
Rarely needed
The story file’s text, and what the importer uses to fill the asset. Update stories with Update in the Inspector rather than these.
BeatPickerAttribute
attributeusing PoetixSDK;
Turns a string field in your own script into the searchable beat menu the Dialogue Starter uses, so designers pick beats instead of typing names.
Members
The field on the same script that holds the story (a StoryAsset or a DialogueManager). "storyAsset" by default.
What you receive#
The data Poetix hands your code in events and properties. You read these; you don’t create them.
SimLine
classusing PoetixSDK.Core;
A line ready to show, from Poetix.LineReady or Poetix.CurrentLine.
Members
The speaking character’s name, ready to show. Empty for a line with no character.
The speaking character’s ID, for finding their portrait with StoryAsset.GetPortrait. Show SpeakerName to players, never the ID.
The beat’s choices, on its last line only. HasValidChoices is true when at least one can be picked.
The variable changes this line made, as data and as readable text such as gold +5.
How the line’s condition was checked, or null when it has none.
The line’s ID in the story, and any {{name}} in its text that matched no variable, or several.
SimChoice
classusing PoetixSDK.Core;
A choice offered to the player, from Poetix.ChoicesReady or Poetix.CurrentChoices. Pass it to Poetix.Choose.
Members
How its condition was checked, or null when it has none. ConditionEval?.Result == false means it is locked and can’t be picked.
The variable changes picking it will make, as data and as readable text.
The choice’s ID, the ID of the beat it leads to (empty when it leads nowhere), and any {{name}} that matched no variable.
SimResult
classusing PoetixSDK.Core;
One variable change made by a line or a choice.
ConditionEval
classusing PoetixSDK.Core;
How a line’s or choice’s condition was checked.
Members
The condition as readable text, such as gold >= 3; each part of it; and how the parts combine ("&&" for all of them, "||" for any).
DialogueHistoryEntry
classusing PoetixSDK.Core;
One line shown, or one choice picked, in Poetix.History.
Members
Who spoke it. Empty for choices and lines with no character.
The beat it belongs to, and when it happened (UTC).
OnVarChangedDetails
classusing PoetixSDK.Core;
A variable change, from DialogueManager.OnVarChanged.
Helpers for your own UI#
What the Dialogue Box uses to lay out choices, available to your own UI so it can number and lock choices the same way.
ChoiceDisplayBuilder
static classusing PoetixSDK.Core;
Decides which choices to show and how to label them: locked choices are left out unless you ask for them, and the first nine pickable ones get a number matching the number keys.
Members
The entries to show, in story order. numberFormat goes before each pickable choice, with {0} for its number, or null for none. numerals can be Roman; numberColor is an optional rich-text color like "#C0392B".
A number in Arabic or Roman numerals.
ChoiceDisplayEntry
structusing PoetixSDK.Core;
One choice as ChoiceDisplayBuilder.Build lays it out.
Members
The text for the button, including the number when one was asked for.
Whether its condition failed, and the condition, when known. Locked choices can’t be picked.
Its number key, 1–9, or 0 for locked choices and choices after the ninth.
Options#
Values you pass to the members above.
LayoutPreset
enumusing PoetixSDK.Core.Layout;
A Dialogue Box layout, for DialogueBox.ApplyLayout.
Guide: Themes & Layouts
Values
The box at the bottom, portrait left, name above the line, choices above the box.
Like Classic, with the name on the box’s top edge and choices at the right.
Like Classic, with the name centered on the box’s top edge.
A full-width box, the name on its top edge, choices at the right.
A large portrait standing on a full-width box, choices in the middle.
Centered text at the bottom with no panel or portrait.
A preset whose settings were changed by hand.
Arrange Pieces by Hand: the layout leaves the parts where you put them.
LockedChoiceDisplay
enumusing PoetixSDK.UI;
How the Dialogue Box shows choices whose condition failed, for DialogueBox.LockedChoices.