Adventure Creator  1.79.1
An adventure game toolkit for Unity, by Chris Burton, ICEBOX Studios 2013-2022
AC.Dialog Class Reference
Inheritance diagram for AC.Dialog:

Public Member Functions

void _Update ()
 
void _LateUpdate ()
 
Speech StartDialog (Char _speaker, string _text, bool isBackground=false, int lineID=-1, bool noAnimation=false, bool preventSkipping=false, AudioClip audioOverride=null, TextAsset lipsyncOverride=null)
 Initialises a new Speech line. More...
 
Speech StartDialog (Char _speaker, int lineID, bool isBackground=false, bool noAnimation=false)
 Initialises a new Speech line. This differs from the other StartDialog function in that it requires a lineID, which must be present in the Speech Manager and is used to source the line's actual text. More...
 
AudioSource GetNarratorAudioSource ()
 Gets, and creates if necessary, an AudioSource used for Narration speech. If the narratorSound variable is empty, one will be generated and its AudioSource referenced. More...
 
virtual void PlayScrollAudio (AC.Char _speaker)
 Plays text-scoll audio for a given character. If no character is speaking, narration text-scroll audio will be played instead. More...
 
Speech GetLatestSpeech (Menu menu=null)
 Gets the last Speech line to be played. More...
 
Speech GetLiveSpeechWithID (int lineID)
 Gets a speech line with a specific ID, that's currently being spoken More...
 
bool FoundAudio ()
 Checks if any of the active Speech lines have audio. More...
 
bool IsAnySpeechPlaying (bool ignoreBackgroundSpeech=false)
 Checks if any speech is currently playing. More...
 
string GetSpeaker (int languageNumber=0)
 Gets the display name of the most recently-speaking character. More...
 
bool CharacterIsSpeaking (Char _char)
 Checks if a given character is speaking. More...
 
bool NarrationIsPlaying ()
 Checks if narration is currently playing. More...
 
bool LineIsPlaying (int lineID)
 Checks if a speech line with a given ID is currently playing. More...
 
AC.Char GetSpeakingCharacter ()
 Gets the most recently-speaking character. More...
 
bool AudioIsPlaying ()
 Checks if any of the active Speech lines have audio and are playing it. More...
 
void KillDialog (bool stopCharacter, bool forceMenusOff, SpeechMenuLimit speechMenuLimit=SpeechMenuLimit.All, SpeechMenuType speechMenuType=SpeechMenuType.All, string limitToCharacters="")
 Kills all active Speech lines. More...
 
void KillDialog (Speech speech)
 Kills a given Speech line. More...
 
virtual List< LipSyncShapeGenerateLipSyncShapes (LipSyncMode _lipSyncMode, int lineID, Char _speaker, string language="", string _message="", TextAsset lipsyncOverride=null, AudioClip audioClip=null)
 Generates the animation data for lipsyncing a given Speech line. More...
 
void EndSpeechByCharacter (Char character)
 Ends speech spoken by a given character More...
 
void OnInitialiseScene ()
 

Public Attributes

List< SpeechspeechList = new List<Speech>()
 
Sound narratorSound
 
float conversationDelay = 0.3f
 
string[] richTextTags
 

Protected Member Functions

void OnEnable ()
 
void OnDisable ()
 
void OnDestroy ()
 
void OnChangeVolume (SoundType soundType, float newVolume)
 
void EndBackgroundSpeechAudio (Speech speech)
 
void EndSpeech (int i, bool stopCharacter=false)
 

Protected Attributes

AudioSource defaultAudioSource
 
AudioSource narratorAudioSource
 
string[] speechEventTokenKeys = new string[0]
 

Properties

string[] SpeechEventTokenKeys [get, set]
 

Detailed Description

Manages the creation, updating, and removal of all Speech lines. It should be placed on the GameEngine prefab.

Member Function Documentation

◆ _Update()

void AC.Dialog._Update ( )

Updates all active Speech lines. This is called every frame by StateHandler.

◆ AudioIsPlaying()

bool AC.Dialog.AudioIsPlaying ( )

Checks if any of the active Speech lines have audio and are playing it.

Returns
True if any active Speech lines have audio and are playing it

◆ CharacterIsSpeaking()

bool AC.Dialog.CharacterIsSpeaking ( Char  _char)

Checks if a given character is speaking.

<param name = "_char".The character to check

Returns
True if the character is speaking

◆ EndSpeechByCharacter()

void AC.Dialog.EndSpeechByCharacter ( Char  character)

Ends speech spoken by a given character

Parameters
characterThe character to stop speaking

◆ FoundAudio()

bool AC.Dialog.FoundAudio ( )

Checks if any of the active Speech lines have audio.

Returns
True if any active Speech lines have audio

◆ GenerateLipSyncShapes()

virtual List<LipSyncShape> AC.Dialog.GenerateLipSyncShapes ( LipSyncMode  _lipSyncMode,
int  lineID,
Char  _speaker,
string  language = "",
string  _message = "",
TextAsset  lipsyncOverride = null,
AudioClip  audioClip = null 
)
virtual

Generates the animation data for lipsyncing a given Speech line.

Parameters
_lipSyncModeThe chosen method of lipsyncing (Off, FromSpeechText, ReadPamelaFile, ReadSapiFile, ReadPapagayoFile, FaceFX, Salsa2D)
lineIDThe speech line's ID number
_speakerThe speaking character
languageThe name of the current language
_messageThe speech text
lipsyncOverrideIf set, this asset's text will be used for lipsyncing data, instead of the default
audioClipIf set, shapes generated from speech text will be timed according to the clip's length
Returns
A List of LipSyncShape structs that contain the lipsync animation data

◆ GetLatestSpeech()

Speech AC.Dialog.GetLatestSpeech ( Menu  menu = null)

Gets the last Speech line to be played.

Parameters
menuIf set, the Speech must be compatible with the Menu's properties
Returns
The last item in the speechList List

◆ GetLiveSpeechWithID()

Speech AC.Dialog.GetLiveSpeechWithID ( int  lineID)

Gets a speech line with a specific ID, that's currently being spoken

Parameters
lineIDThe ID number of the speech line to get
Returns
The active speech line

◆ GetNarratorAudioSource()

AudioSource AC.Dialog.GetNarratorAudioSource ( )

Gets, and creates if necessary, an AudioSource used for Narration speech. If the narratorSound variable is empty, one will be generated and its AudioSource referenced.

Returns
The AudioSource for Narration speech

◆ GetSpeaker()

string AC.Dialog.GetSpeaker ( int  languageNumber = 0)

Gets the display name of the most recently-speaking character.

Parameters
languageNumberThe index number of the language number to get the text in
Returns
The character's display name

◆ GetSpeakingCharacter()

AC.Char AC.Dialog.GetSpeakingCharacter ( )

Gets the most recently-speaking character.

Returns
The character

◆ IsAnySpeechPlaying()

bool AC.Dialog.IsAnySpeechPlaying ( bool  ignoreBackgroundSpeech = false)

Checks if any speech is currently playing.

Parameters
ignoreBackgroundSpeechIf True, then only gameplay-blocking speech will be accounted for
Returns
True if any speech is currently playing

◆ KillDialog() [1/2]

void AC.Dialog.KillDialog ( bool  stopCharacter,
bool  forceMenusOff,
SpeechMenuLimit  speechMenuLimit = SpeechMenuLimit.All,
SpeechMenuType  speechMenuType = SpeechMenuType.All,
string  limitToCharacters = "" 
)

Kills all active Speech lines.

Parameters
stopCharacterIf True, then all characters speaking will cease their talking animation
forceMenusOffTrue if subtitles should be turned off immediately
speechMenuLimitThe type of speech to kill (All, BlockingOnly, BackgroundOnly)

◆ KillDialog() [2/2]

void AC.Dialog.KillDialog ( Speech  speech)

Kills a given Speech line.

Parameters
speechThe Speech class instance to end.
stopCharacterIf True, then the speaking character will cease their talking animation

◆ LineIsPlaying()

bool AC.Dialog.LineIsPlaying ( int  lineID)

Checks if a speech line with a given ID is currently playing.

<param name = "lineID".The line ID to check

Returns
True if the line is playing

◆ NarrationIsPlaying()

bool AC.Dialog.NarrationIsPlaying ( )

Checks if narration is currently playing.

Returns
True if narrtion is currently playing

◆ PlayScrollAudio()

virtual void AC.Dialog.PlayScrollAudio ( AC.Char  _speaker)
virtual

Plays text-scoll audio for a given character. If no character is speaking, narration text-scroll audio will be played instead.

Parameters
_speakerThe speaking character

◆ StartDialog() [1/2]

Speech AC.Dialog.StartDialog ( Char  _speaker,
int  lineID,
bool  isBackground = false,
bool  noAnimation = false 
)

Initialises a new Speech line. This differs from the other StartDialog function in that it requires a lineID, which must be present in the Speech Manager and is used to source the line's actual text.

Parameters
_speakerThe speaking character. If null, the line will be treated as narration
lineIDThe ID number of the line, if it is listed in the Speech Manager
isBackgroundTrue if the line should play in the background, and not interrupt any Actions or gameplay
noAnimationTrue if the character should not play a talking animation
Returns
The generated Speech line

◆ StartDialog() [2/2]

Speech AC.Dialog.StartDialog ( Char  _speaker,
string  _text,
bool  isBackground = false,
int  lineID = -1,
bool  noAnimation = false,
bool  preventSkipping = false,
AudioClip  audioOverride = null,
TextAsset  lipsyncOverride = null 
)

Initialises a new Speech line.

Parameters
_speakerThe speaking character. If null, the line will be treated as narration
_textThe subtitle text to display
isBackgroundTrue if the line should play in the background, and not interrupt any Actions or gameplay
lineIDThe ID number of the line, if it is listed in the Speech Manager
noAnimationTrue if the character should not play a talking animation
preventSkippingTrue if the speech cannot be skipped regardless of subtitle settings in the Speech Manager
audioOverrideIf set, then this audio will be played instead of the one assigned via the Speech Manager given the line ID and language
lipsyncOverrideIf set, then this lipsync text asset will be played instead of the one assigned via the Speech Manager given the line ID and language
Returns
The generated Speech line

Member Data Documentation

◆ conversationDelay

float AC.Dialog.conversationDelay = 0.3f

The delay in seconds between choosing a Conversation's dialogue option and it triggering

◆ narratorSound

Sound AC.Dialog.narratorSound

The Sound prefab to use to play narration speech audio from

◆ richTextTags

string [] AC.Dialog.richTextTags
Initial value:
= new string[]
{
"b",
"i",
"size=",
"color="
}

An array of rich-text tag names that can be detected when scrolling speech, to prevent them from displaying incorrectly. If a name ends with an '=' symbol, the tag has a parameter

◆ speechList

List<Speech> AC.Dialog.speechList = new List<Speech>()

A List of all active Speech lines

Property Documentation

◆ SpeechEventTokenKeys

string [] AC.Dialog.SpeechEventTokenKeys
getset

An array of string keys that can be inserted into speech text in the form [key:value]. When processed by the speech display, they will be removed from the speech, but will trigger the OnSpeechToken and OnRequestSpeechTokenReplacement events.