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#

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 class

using 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.

Poetix.Play("Campfire Greeting"); int gold = Poetix.GetVar<int>("Gold"); Poetix.SetVar("Gold", gold + 10);

Guide: Controlling Dialogue from Code

Conversations

Playmethod#
static bool Play(string? beat = null, bool restart = false) static bool Play(StoryAsset story, string? beat = null, bool restart = false)

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.

Poetix.Play("Kael - Campfire Greeting");
Stopmethod#
static void Stop()

Ends the conversation that is playing, if any.

IsPlayingproperty#
static bool IsPlaying { get; }

True while a conversation is playing. Check it to freeze your player during dialogue.

void Update() { if (Poetix.IsPlaying) return; // movement }
Started, Endedevent#
static event Action Started static event Action Ended

Fired when a conversation starts and when it ends. Subscribe in OnEnable and unsubscribe in OnDisable.

Variables

GetVarmethod#
static T GetVar<T>(string name, T defaultValue = default)

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.

int gold = Poetix.GetVar<int>("Gold");
SetVarmethod#
static void SetVar(string name, object value)

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.

Poetix.SetVar("Has Relic", true);
WatchVarmethod#
static IDisposable WatchVar<T>(string name, Action<T, T> onChange, bool callNow = false, UnityEngine.Object? owner = null)

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.

Poetix.WatchVar<int>("Gold", (before, after) => label.text = after.ToString(), callNow: true);

Your own dialogue UI

LineReadyevent#
static event Action<SimLine> LineReady

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.

ChoicesReadyevent#
static event Action<IReadOnlyList<SimChoice>> ChoicesReady

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.

ChoicePickedevent#
static event Action<SimChoice> ChoicePicked

Fired when the player picks a choice, before its results are applied. Choices picked by auto-choice beats don’t fire it.

Continuemethod#
static void Continue()

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.

Choosemethod#
static void Choose(SimChoice choice) static void Choose(int index)

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.

CurrentLine, CurrentChoicesproperty#
static SimLine? CurrentLine { get; } static IReadOnlyList<SimChoice> CurrentChoices { get; }

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

BlockInput, UnblockInputmethod#
static void BlockInput(object owner) static void UnblockInput(object owner)

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.

void OnEnable() => Poetix.BlockInput(this); void OnDisable() => Poetix.UnblockInput(this);
IsInputBlockedproperty#
static bool IsInputBlocked { get; }

True while dialogue ignores the player’s keys and clicks: something blocked it, or the player is typing in a text field.

History

Historyproperty#
static IReadOnlyList<DialogueHistoryEntry> History { get; }

The lines shown and choices picked so far, oldest first, up to the Dialogue Manager’s History Size. For a backlog or journal screen.

HistoryAddedevent#
static event Action<DialogueHistoryEntry> HistoryAdded

Fired when a line or picked choice is added to History.

ClearHistorymethod#
static void ClearHistory()

Empties History.

Saving

SaveStatemethod#
static string SaveState()

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.

mySave.dialogue = Poetix.SaveState();
LoadStatemethod#
static void LoadState(string state)

Restores text from SaveState. A save made during a conversation reopens it at the saved line. Saves made before a story update still load.

ResetStatemethod#
static void ResetState()

Ends any conversation and sets every variable of every story back to its starting value, for a new game.

DialogueState

static class

using 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

IsActiveproperty#
static bool IsActive { get; }

True while any Dialogue Manager is playing a conversation.

Started, Endedevent#
static event Action Started static event Action Ended

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 class

using PoetixSDK;

Whether dialogue should ignore input right now. Poetix.BlockInput and Poetix.IsInputBlocked cover the usual needs.

Members

Block, Unblockmethod#
static void Block(object owner) static void Unblock(object owner)

Same as Poetix.BlockInput and Poetix.UnblockInput. Blocking twice with one owner needs only one unblock.

IsBlockedproperty#
static bool IsBlocked { get; }

True while something blocks input or the player is typing in a text field.

HasBlockersproperty#
static bool HasBlockers { get; }

True while at least one owner has blocked input and not unblocked it.

IsTypingInTextFieldproperty#
static bool IsTypingInTextField { get; }

True while a UI text field (TextMesh Pro or legacy) or a Poetix overlay such as the Debug Menu has keyboard focus.

IsPointerOverOverlayproperty#
static bool IsPointerOverOverlay { get; }

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

component

using 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.

var starter = GetComponent<DialogueStarter>(); starter.StartingBeatName = "Kael - Campfire Greeting"; starter.Play();

Guide: Starting Dialogues Without Code

Starting

Playmethod#
void Play()

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.

TryPlaymethod#
bool TryPlay()

Same as Play, and returns whether the conversation started.

Settings

StoryAssetproperty#
StoryAsset? StoryAsset { get; set; }

The story this object starts. Null uses the Dialogue Manager’s story.

Inspector: Story

StartingBeatNameproperty#
string StartingBeatName { get; set; }

The beat the conversation begins with. Empty starts from the story’s root beat.

Inspector: Start From

StartOnproperty#
DialogueStarter.StartMode StartOn { get; set; }

What starts the conversation: StartMode.Manually, WhenPlayerEnters, InteractKeyInRange, or WhenClicked.

Inspector: Start On

ClickOnlyInRangeproperty#
bool ClickOnlyInRange { get; set; }

With WhenClicked, clicks only count while the player is in range. Turn off for point-and-click games.

Inspector: Only in Range

PlayOnceproperty#
bool PlayOnce { get; set; }

Start the conversation only the first time.

Inspector: Play Once

HasPlayedproperty#
bool HasPlayed { get; set; }

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.

InteractionPromptproperty#
GameObject? InteractionPrompt { get; set; }

An object shown while the conversation can start, such as an “[E] Talk” label.

Inspector: Prompt

TargetManagerproperty#
DialogueManager? TargetManager { get; set; }

The Dialogue Manager that plays the conversation. Null uses the scene’s.

Inspector: Advanced > Dialogue Manager

State

IsPlayerInRangeproperty#
bool IsPlayerInRange { get; }

True while the player is inside this object’s trigger. Always false in Manually.

IsPointerOverproperty#
bool IsPointerOver { get; }

True while the mouse is over the character and a click would start the conversation (WhenClicked).

Events

OnPlayerEntered, OnPlayerEnteredEvent, OnPlayerExited, OnPlayerExitedEventevent#
event Action OnPlayerEntered event Action OnPlayerExited UnityEvent OnPlayerEnteredEvent { get; } UnityEvent OnPlayerExitedEvent { get; }

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

OnPointerEntered, OnPointerEnteredEvent, OnPointerExited, OnPointerExitedEventevent#
event Action OnPointerEntered event Action OnPointerExited UnityEvent OnPointerEnteredEvent { get; } UnityEvent OnPointerExitedEvent { get; }

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

OnDialogueStarted, OnDialogueStartedEvent, OnDialogueEnded, OnDialogueEndedEventevent#
event Action OnDialogueStarted event Action OnDialogueEnded UnityEvent OnDialogueStartedEvent { get; } UnityEvent OnDialogueEndedEvent { get; }

This object’s conversation begins or ends.

Inspector: Events > On Dialogue Started / On Dialogue Ended

DialogueBox

component

using 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.

using PoetixSDK.UI; DialogueBox.Instance.AutoAdvance = true; DialogueBox.Instance.ActiveTheme = dreamTheme;

Guide: The Dialogue Box

Finding it

Instanceproperty#
static DialogueBox? Instance { get; }

The Dialogue Box in the scene, or null when there is none.

Theme and layout

ActiveThemeproperty#
DialogueTheme? ActiveTheme { get; set; }

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

EffectiveThemeproperty#
DialogueTheme? EffectiveTheme { get; }

The theme actually shown: ActiveTheme, or Modern Minimal when that theme’s asset is missing. Null only when no theme was chosen on purpose.

ApplyLayoutmethod#
void ApplyLayout(LayoutPreset preset)

Switches to a layout preset.

Inspector: Layout > Preset

DialogueBox.Instance.ApplyLayout(LayoutPreset.Subtitles);
Layoutproperty#
DialogueLayoutSettings Layout { get; }

The layout’s settings: preset, boxPosition, boxWidth, boxHeight, choices, portrait, name, lineAlignment and showPanel. After changing them, call RefreshLayout.

Inspector: Layout

RefreshLayoutmethod#
void RefreshLayout()

Applies changes made to Layout from code.

Text and pacing

UseTypewriterproperty#
bool UseTypewriter { get; set; }

Type lines out letter by letter. When false, each line appears in full.

Inspector: Text & Pacing > Text Reveal

TypingSpeedproperty#
float TypingSpeed { get; set; }

Seconds per letter while typing (0.025 by default). Lower is faster.

Inspector: Text & Pacing > Speed

PauseAfterCommas, PauseAfterSentencesproperty#
float PauseAfterCommas { get; set; } float PauseAfterSentences { get; set; }

Extra seconds after , ; : — and after . ! ? while typing. 0 for no pause.

Inspector: Text & Pacing > Pause After Commas / Pause After Sentences

AutoAdvance, AutoAdvanceDelay, AutoAdvancePerCharacterproperty#
bool AutoAdvance { get; set; } float AutoAdvanceDelay { get; set; } float AutoAdvancePerCharacter { get; set; }

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

EnableFastForward, FastForwardLineDelayproperty#
bool EnableFastForward { get; set; } float FastForwardLineDelay { get; set; }

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

IsFastForwardingproperty#
bool IsFastForwarding { get; }

True while the player is fast-forwarding.

Keys

AdvanceWithSpace, AdvanceWithEnter, AdvanceWithE, EnableClickToAdvance, AdvanceWithGamepadproperty#
bool AdvanceWithSpace { get; set; } bool AdvanceWithEnter { get; set; } bool AdvanceWithE { get; set; } bool EnableClickToAdvance { get; set; } bool AdvanceWithGamepad { get; set; }

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

FastForwardWithCtrl, FastForwardWithTab, FastForwardWithGamepadproperty#
bool FastForwardWithCtrl { get; set; } bool FastForwardWithTab { get; set; } bool FastForwardWithGamepad { get; set; }

Which keys fast-forward while held: Ctrl, Tab, and the gamepad’s right shoulder button.

Inspector: Input & Choices > Fast Forward

NavigateWithArrows, NavigateWithWS, NavigateWithGamepadproperty#
bool NavigateWithArrows { get; set; } bool NavigateWithWS { get; set; } bool NavigateWithGamepad { get; set; }

Which keys move the highlight up and down between choices. Turn off the ones that move your player.

Inspector: Input & Choices > Move Highlight

PickWithEnter, PickWithSpace, PickWithGamepad, ChooseWithNumberKeysproperty#
bool PickWithEnter { get; set; } bool PickWithSpace { get; set; } bool PickWithGamepad { get; set; } bool ChooseWithNumberKeys { get; set; }

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

ContinueKeyNameproperty#
string ContinueKeyName { get; }

The name of the key that continues, as the theme’s key hint shows it. Empty when only clicking continues.

Choices

LockedChoicesproperty#
LockedChoiceDisplay LockedChoices { get; set; }

How choices whose condition failed are shown: Hidden (the default), GreyedOut, or GreyedOutWithLock.

Inspector: Input & Choices > Locked Choices

AutoFocusFirstChoiceproperty#
bool AutoFocusFirstChoice { get; set; }

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

ChoiceInputDelayproperty#
float ChoiceInputDelay { get; set; }

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

ShowFailedConditions, AreFailedConditionsShownproperty#
bool ShowFailedConditions { get; set; } bool AreFailedConditionsShown { get; }

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

SetPortraitResolvermethod#
void SetPortraitResolver(Func<string, Sprite?>? resolver)

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.

box.SetPortraitResolver(id => metCharacters.Contains(id) ? null : silhouette);
SetSpeakerNameResolvermethod#
void SetSpeakerNameResolver(Func<string, string?>? resolver)

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.

box.SetSpeakerNameResolver(id => metCharacters.Contains(id) ? null : "???");
SetPortraitmethod#
void SetPortrait(Sprite? portrait)

The portrait used for characters that have none of their own, shown right away.

FindPortraitmethod#
Sprite? FindPortrait(string characterId)

A character’s portrait from the story being played, or null when it has none.

Sound and time

AudioConfigproperty#
DialogueAudioConfig AudioConfig { get; }

The box’s sound settings and hooks. See DialogueAudioConfig.

Inspector: Audio

PlayTypingSound, TypingSoundEveryproperty#
bool PlayTypingSound { get; set; } int TypingSoundEvery { get; set; }

Play the theme’s typing sound while a line types, once every N letters (spaces skipped).

Inspector: Audio > Typing Sound, Every N Letters

PauseWithGameTimeproperty#
bool PauseWithGameTime { get; set; }

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

TextScaleproperty#
static float TextScale { get; set; }

Text size of every Dialogue Box, from 0.75 to 2, where 1 is the theme’s size. Offer it in your options menu.

ReduceMotionproperty#
static bool ReduceMotion { get; set; }

Turns off the theme’s animations (opening, closing, choices appearing, the continue prompt, highlight growth) in every Dialogue Box.

PlayerSettingsChangedevent#
static event Action PlayerSettingsChanged

Fired when TextScale or ReduceMotion changes.

Rarely needed

AdvanceOrCompleteTypingmethod#
void AdvanceOrCompleteTyping()

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.

CompleteTypingImmediatelymethod#
void CompleteTypingImmediately()

Shows the rest of the line being typed, and its choices if it has any.

SelectChoiceByIndexmethod#
void SelectChoiceByIndex(int index)

Picks one of the choices the box is showing, 0 being the first pickable one. Poetix.Choose does the same for any UI.

StopDialoguemethod#
void StopDialogue()

Ends the conversation and closes the box. Same as Poetix.Stop.

ApplyTheme, ClearThememethod#
void ApplyTheme(DialogueTheme theme) void ClearTheme()

Apply or remove a theme. Setting ActiveTheme does the same.

ChoiceButtonPrefab, ContinueButton, Partsproperty#
GameObject? ChoiceButtonPrefab { get; set; } Button? ContinueButton { get; set; } DialogueBoxParts Parts { get; }

The parts of the box the script drives. Already connected in the built-in box; change them only for your own layout.

Inspector: UI References

DialogueAudioConfig

class

using 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.

var audio = DialogueBox.Instance.AudioConfig; audio.CustomPlayOpen = () => FMODUnity.RuntimeManager.PlayOneShot("event:/UI/DialogueOpen");

Settings

Volumeproperty#
float Volume { get; set; }

Volume of all dialogue sounds, 0 to 1. Each sound’s own volume is set in the theme.

Inspector: Audio > Volume

Outputproperty#
AudioMixerGroup? Output { get; set; }

The Audio Mixer group dialogue sounds play through, such as your SFX group.

Inspector: Audio > Output

AudioSourceproperty#
AudioSource? AudioSource { get; set; }

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

CustomPlayOpen, CustomPlayClose, CustomPlayNext, CustomPlayChoiceHover, CustomPlayChoiceSelect, CustomPlayTypewriterBlipproperty#
Action? CustomPlayOpen { get; set; } Action? CustomPlayClose { get; set; } Action? CustomPlayNext { get; set; } Action? CustomPlayChoiceHover { get; set; } Action? CustomPlayChoiceSelect { get; set; } Action? CustomPlayTypewriterBlip { get; set; }

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.

audio.CustomPlayTypewriterBlip = () => myVoices.PlayBlip(Poetix.CurrentLine?.CharacterId);

Rarely needed

PlayOpen, PlayClose, PlayNext, PlayChoiceHover, PlayChoiceSelect, PlayTypewriterBlipmethod#
void PlayOpen() void PlayClose() void PlayNext() void PlayChoiceHover() void PlayChoiceSelect() void PlayTypewriterBlip(AudioClip? overrideClip = null, float basePitch = 1f)

Play one of the dialogue sounds now, or its custom hook when one is set.

UseTheme, Initializemethod#
void UseTheme(DialogueTheme? theme) void Initialize(GameObject host)

Used by the Dialogue Box to set up its sounds. You don’t need to call them.

DialogueManager

component

using 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

Instanceproperty#
static DialogueManager? Instance { get; }

The scene’s Dialogue Manager, the one Poetix talks to.

Settings

StoryAssetproperty#
StoryAsset? StoryAsset { get; set; }

The story it plays. A change takes effect at the next conversation.

Inspector: Story

PlayOnStart, StartingBeatNameproperty#
bool PlayOnStart { get; set; } string StartingBeatName { get; set; }

Start a conversation as soon as the scene loads, from this beat (empty for the root beat).

Inspector: Play When Scene Starts, Start From

DontDestroyOnLoadEnabledproperty#
bool DontDestroyOnLoadEnabled { get; set; }

Keep this object, and its Dialogue Box, when a new scene loads.

Inspector: Advanced > Keep Between Scenes

MaxHistoryCapacityproperty#
int MaxHistoryCapacity { get; set; }

How many past lines and picked choices the history keeps (100 by default).

Inspector: Advanced > History Size

StrictMode, IsStrictproperty#
bool StrictMode { get; set; } bool IsStrict { get; }

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

StartDialogue, StopDialogue, IsDialogueActivemethod#
bool StartDialogue(string? beatName = null, bool restart = false) bool StartDialogue(StoryAsset story, string? startingBeatName = null, bool restart = false) void StopDialogue() bool IsDialogueActive { get; }

This manager’s Poetix.Play, Poetix.Stop and whether it is playing.

Continue, SelectChoice, CurrentLine, CurrentChoicesmethod#
void Continue() void SelectChoice(string choiceId) SimLine? CurrentLine { get; } IReadOnlyList<SimChoice> CurrentChoices { get; }

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.

GetVar, SetVarmethod#
T GetVar<T>(string varName, T defaultValue = default) void SetVar(string varName, object value)

Read and change variables of this manager’s story, by name or ID.

GetHistory, ClearHistorymethod#
IReadOnlyList<DialogueHistoryEntry> GetHistory() void ClearHistory()

This manager’s history, and emptying it.

ExportStateJson, ImportStateJson, ResetStatemethod#
string ExportStateJson() void ImportStateJson(string json) void ResetState()

Poetix.SaveState, LoadState and ResetState.

Events

OnDialogueStarted, OnDialogueEnded, OnDialogueStartedEvent, OnDialogueEndedEventevent#
event Action OnDialogueStarted event Action OnDialogueEnded UnityEvent OnDialogueStartedEvent { get; } UnityEvent OnDialogueEndedEvent { get; }

This manager’s conversation begins or ends.

Inspector: Events > On Dialogue Started / On Dialogue Ended

OnLineReady, OnLineShownEventevent#
event Action<SimLine> OnLineReady UnityEvent<string> OnLineShownEvent { get; }

A line is ready to show. The UnityEvent passes only its text.

Inspector: Events > On Line Shown

OnChoicesReadyevent#
event Action<IReadOnlyList<SimChoice>> OnChoicesReady

Choices are waiting for the player.

OnChoiceSelected, OnChoicePickedEventevent#
event Action<SimChoice> OnChoiceSelected UnityEvent<string> OnChoicePickedEvent { get; }

The player picked a choice, before its results apply. The UnityEvent passes its text.

Inspector: Events > On Choice Picked

OnVarChangedevent#
event Action<OnVarChangedDetails> OnVarChanged

Any variable of this manager’s story changed. Poetix.WatchVar is simpler for one variable.

OnHistoryEntryAddedevent#
event Action<DialogueHistoryEntry> OnHistoryEntryAdded

A line or picked choice was added to the history.

OnStateRestoredevent#
event Action OnStateRestored

Variables were loaded from a save or reset.

Rarely needed

GetCharacterName, TryGetCharacterNamemethod#
string GetCharacterName(string characterId) bool TryGetCharacterName(string characterId, out string displayName)

A character’s name from the story, ready to show. Lines already carry it as SimLine.SpeakerName.

ResetBlackboard, ClearGlobalBlackboardCachemethod#
void ResetBlackboard() static void ClearGlobalBlackboardCache()

Reset only this story’s variables, keeping the conversation playing; or forget every story’s variables. Poetix.ResetState is the usual “new game”.

GetAllVariablesmethod#
List<StoryVarSnapshot> GetAllVariables()

Every variable with its current value, as the Debug Menu shows them.

OnConditionEvaluated, OnTrace, OnDiagnostic, TraceHistory, LastConditionEvalevent#
event Action<ConditionEval> OnConditionEvaluated event Action<SimulatorTraceEvent> OnTrace event Action<SimulatorDiagnostic> OnDiagnostic IReadOnlyList<SimulatorTraceEvent> TraceHistory { get; } ConditionEval? LastConditionEval { get; }

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.

Simulator, GetOrParseStory, InvalidateStoryCacheproperty#
SceneSimulatorManager? Simulator { get; } Story? GetOrParseStory() void InvalidateStoryCache()

The plain C# engine playing the story, and the parsed story. For tools that need the story’s raw data.

StoryAsset

asset

using 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

GetPortraitmethod#
Sprite? GetPortrait(string? characterId)

A character’s portrait, or null when it has none. Pass a line’s CharacterId.

portraitImage.sprite = story.GetPortrait(line.CharacterId);
CharacterPortraitsproperty#
IReadOnlyList<CharacterPortrait> CharacterPortraits { get; }

Every character’s portrait in this story.

Rarely needed

JsonPayload, SetPayload, SetPortraitsproperty#
string JsonPayload { get; } void SetPayload(string payload) void SetPortraits(IEnumerable<CharacterPortrait> portraits)

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

attribute

using 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.

[SerializeField] private StoryAsset storyAsset; [SerializeField, BeatPicker("storyAsset")] private string beat;

Members

StoryAssetFieldNameproperty#
string StoryAssetFieldName { get; }

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

class

using PoetixSDK.Core;

A line ready to show, from Poetix.LineReady or Poetix.CurrentLine.

Members

Textproperty#
string Text { get; }

The line, with {{variables}} already filled in.

SpeakerNameproperty#
string SpeakerName { get; }

The speaking character’s name, ready to show. Empty for a line with no character.

CharacterIdproperty#
string CharacterId { get; }

The speaking character’s ID, for finding their portrait with StoryAsset.GetPortrait. Show SpeakerName to players, never the ID.

IsLastLineproperty#
bool IsLastLine { get; }

True for the last line of its beat.

Choices, HasValidChoicesproperty#
List<SimChoice> Choices { get; } bool HasValidChoices { get; }

The beat’s choices, on its last line only. HasValidChoices is true when at least one can be picked.

Results, ResultsExpressionsproperty#
List<SimResult> Results { get; } List<string> ResultsExpressions { get; }

The variable changes this line made, as data and as readable text such as gold +5.

ConditionEvalproperty#
ConditionEval? ConditionEval { get; }

How the line’s condition was checked, or null when it has none.

LineId, InterpolationIssuesproperty#
string LineId { get; } List<InterpolationIssue> InterpolationIssues { get; }

The line’s ID in the story, and any {{name}} in its text that matched no variable, or several.

SimChoice

class

using PoetixSDK.Core;

A choice offered to the player, from Poetix.ChoicesReady or Poetix.CurrentChoices. Pass it to Poetix.Choose.

Members

Textproperty#
string Text { get; }

The choice’s text, with {{variables}} filled in.

ConditionEvalproperty#
ConditionEval? ConditionEval { get; }

How its condition was checked, or null when it has none. ConditionEval?.Result == false means it is locked and can’t be picked.

bool locked = choice.ConditionEval?.Result == false;
Results, ResultsExpressionsproperty#
List<SimResult> Results { get; } List<string> ResultsExpressions { get; }

The variable changes picking it will make, as data and as readable text.

Id, NextBeatId, InterpolationIssuesproperty#
string Id { get; } string NextBeatId { get; } List<InterpolationIssue> InterpolationIssues { get; }

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

class

using PoetixSDK.Core;

One variable change made by a line or a choice.

Members

VarName, VarIdproperty#
string VarName { get; } string VarId { get; }

The variable’s name and ID.

Action, Valueproperty#
string Action { get; } StoryValue Value { get; }

What it does, "set", "increment" or "decrement", and by how much.

ConditionEval

class

using PoetixSDK.Core;

How a line’s or choice’s condition was checked.

Members

Resultproperty#
bool Result { get; }

True when the condition passed.

Expression, Clauses, Logicproperty#
string Expression { get; } List<ConditionClause> Clauses { get; } string Logic { get; }

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

class

using PoetixSDK.Core;

One line shown, or one choice picked, in Poetix.History.

Members

Textproperty#
string Text { get; }

The line or choice as it was shown.

IsChoiceproperty#
bool IsChoice { get; }

True for a choice the player picked.

SpeakerName, CharacterIdproperty#
string SpeakerName { get; } string CharacterId { get; }

Who spoke it. Empty for choices and lines with no character.

BeatName, Timestampproperty#
string BeatName { get; } DateTime Timestamp { get; }

The beat it belongs to, and when it happened (UTC).

OnVarChangedDetails

class

using PoetixSDK.Core;

A variable change, from DialogueManager.OnVarChanged.

Members

Name, Idproperty#
string Name { get; } string Id { get; }

The variable’s name and ID.

PrevValue, NewValueproperty#
StoryValue PrevValue { get; } StoryValue NewValue { get; }

Its value before and after.

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 class

using 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.

foreach (var entry in ChoiceDisplayBuilder.Build(choices, includeLocked: true, numberFormat: "{0}. ")) AddButton(entry.Label, locked: entry.IsLocked);

Members

Buildmethod#
static List<ChoiceDisplayEntry> Build(IReadOnlyList<SimChoice>? choices, bool includeLocked, string? numberFormat, ChoiceNumerals numerals = ChoiceNumerals.Arabic, string? numberColor = null)

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".

Numeralmethod#
static string Numeral(int number, ChoiceNumerals numerals)

A number in Arabic or Roman numerals.

ChoiceDisplayEntry

struct

using PoetixSDK.Core;

One choice as ChoiceDisplayBuilder.Build lays it out.

Members

Labelproperty#
string Label { get; }

The text for the button, including the number when one was asked for.

IsLocked, LockReasonproperty#
bool IsLocked { get; } string? LockReason { get; }

Whether its condition failed, and the condition, when known. Locked choices can’t be picked.

Numberproperty#
int Number { get; }

Its number key, 1–9, or 0 for locked choices and choices after the ninth.

Idproperty#
string Id { get; }

The choice’s ID, matching SimChoice.Id.

Options#

Values you pass to the members above.

LayoutPreset

enum

using PoetixSDK.Core.Layout;

A Dialogue Box layout, for DialogueBox.ApplyLayout.

Guide: Themes & Layouts

Values

Classicvalue#

The box at the bottom, portrait left, name above the line, choices above the box.

SideChoicesvalue#

Like Classic, with the name on the box’s top edge and choices at the right.

Storybookvalue#

Like Classic, with the name centered on the box’s top edge.

JRPGvalue#

A full-width box, the name on its top edge, choices at the right.

VisualNovelvalue#

A large portrait standing on a full-width box, choices in the middle.

Subtitlesvalue#

Centered text at the bottom with no panel or portrait.

Customvalue#

A preset whose settings were changed by hand.

Manualvalue#

Arrange Pieces by Hand: the layout leaves the parts where you put them.

LockedChoiceDisplay

enum

using PoetixSDK.UI;

How the Dialogue Box shows choices whose condition failed, for DialogueBox.LockedChoices.

Values

Hiddenvalue#

Not shown. The default.

GreyedOutvalue#

Shown greyed out; they can’t be picked.

GreyedOutWithLockvalue#

Greyed out with the theme’s lock icon.