Scripting Narrative Design
The complete C# surface of Narrative Design — IConvaiNarrativeDesign events, InvokeTrigger, InvokeSpeech with speak tags, async section fetching, and runtime trigger reconfiguration.
Controlling Narrative Design Programmatically
Accessing the Character API
ConvaiCharacter character = GetComponent<ConvaiCharacter>();
IConvaiNarrativeDesign narrative = character.NarrativeDesign;Properties
Property
Type
Description
Listening to Section Changes
private void OnEnable()
{
character.NarrativeDesign.OnSectionChanged += HandleSectionChanged;
character.NarrativeDesign.OnSectionDataReceived += HandleSectionData;
}
private void OnDisable()
{
character.NarrativeDesign.OnSectionChanged -= HandleSectionChanged;
character.NarrativeDesign.OnSectionDataReceived -= HandleSectionData;
}
private void HandleSectionChanged(string previousId, string newId)
{
Debug.Log($"Section: {previousId} → {newId}");
}
private void HandleSectionData(NarrativeSectionData data)
{
Debug.Log($"Section ID: {data.SectionId}");
// data.BehaviorTreeCode and data.BehaviorTreeConstants available here
}Events
Event
Signature
Description
Invoking Triggers from Code
Controlling What the Character Says
Context Injection (plain text)
Verbatim Speech (speak tags)
Comparison
Pattern
What the character does
Listening to Trigger Invocations
Field
Type
Description
Template Keys via Code
Fetching Sections and Triggers Programmatically
Via the Character API
Via the Static Fetcher
Field
Type
Description
Resetting State
Reconfiguring ConvaiNarrativeDesignTrigger from Code
Architecture Overview
Conclusion
Last updated
Was this helpful?