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

Public Types

enum  ContinueState { None, Pending, Continued }
 

Public Member Functions

 Speech (Char _speaker, string _message, int lineID, bool _isBackground, bool _noAnimation, bool _preventSkipping=false, AudioClip audioOverride=null, TextAsset lipsyncOverride=null)
 The default Constructor. More...
 
 Speech (string _message)
 A special-case Constructor purely used to display text without tags when exporting script-sheets. More...
 
 Speech (AC.Char _speaker, string _message)
 
void UpdateVolume ()
 
void UpdateDisplay ()
 
void EndPause ()
 
bool HasConditions (SpeechMenuLimit speechMenuLimit, SpeechMenuType speechMenuType, string limitToCharacters, SpeechProximityLimit speechProximityLimit=SpeechProximityLimit.NoLimit, float speechProximityDistance=0f)
 Checks if the speech line matches certain conditions. More...
 
void UpdateInput ()
 Updates the state of the Speech based on the user's input. This is called every Update call by StateHandler. More...
 
void EndBackgroundSpeechAudio (AC.Char newSpeaker)
 Ends speech audio, if it is playing in the background. More...
 
void EndSpeechAudio ()
 
string GetSpeaker (int languageNumber=0)
 Gets the display name of the speaking character. More...
 
Color GetColour ()
 Gets the colour of the subtitle text. More...
 
AC.Char GetSpeakingCharacter ()
 Gets the speaking character. More...
 
bool IsPaused ()
 
bool IsScrolling ()
 
bool IsPlayingAudio ()
 
Sprite GetPortraitSprite ()
 Gets a Sprite based on the portrait graphic of the speaking character. If lipsincing is enabled, the sprite will be based on the current phoneme. More...
 
Texture GetPortrait ()
 Gets the portrait graphic of the speaking character. More...
 
bool IsAnimating ()
 Checks if the speaking character's portrait graphic can be animated. More...
 
void ReplaceDisplayText (string newDisplayText, bool resetScrollAmount=true)
 Replaces the speech's display text. Note that this will not affect audio or lipsyncing More...
 
bool MenuCanShow (Menu menu)
 Checks if a Menu is able to show this speech line. More...
 
bool CanScroll ()
 
override string ToString ()
 
void SetCharIndex (int charIndex)
 Sets the scrolling amount to a specific character index. This will not affect the speech's duration, however. More...
 

Static Public Member Functions

static void CreateSkippedSpeech (Char _speaker, string _message, int lineID)
 

Public Attributes

SpeechLog log
 
bool isAlive
 
ContinueState continueState = ContinueState.None
 
bool noAnimation = false
 

Protected Member Functions

void ExtendTime ()
 
void StopScrolling ()
 
void SetPauseGap ()
 
string DetermineGaps (string _text)
 
string DetermineRichTextTags (string _text, string[] tagNames)
 
string FindSpeakerTag (string _message, string _speakerName)
 
void CorrectPreviousGaps (int minCharIndex, int offset)
 
float FloatParse (string text)
 
bool IsBackgroundSpeech ()
 
void EndMessage (bool forceOff=false)
 
bool SkipSpeechInput ()
 
void InitSpeech (string _message, bool resetScrollAmount)
 
bool HasPassedIndex (int indexToCheck)
 
string GetTextPortion (string fullText, int index)
 
float GetLengthWithoutRichText (string _message)
 
float GetTotalWaitTokenDuration ()
 
void AssignAudioClip (AudioClip audioClip)
 

Protected Attributes

int gapIndex = -1
 
int continueIndex = -1
 
List< SpeechGapspeechGaps = new List<SpeechGap>()
 
float endTime
 
float continueTime
 
float minSkipTime
 
bool preventSkipping = false
 
bool usingRichText = false
 
bool isSkippable
 
bool pauseGap
 
bool holdForever = false
 
string originalText
 
float scrollAmount = 0f
 
float pauseEndTime = 0f
 
bool pauseIsIndefinite = false
 
AudioSource audioSource = null
 
bool isRTL = false
 
int currentCharIndex = 0
 
float minDisplayTime
 
string realName
 

Properties

string displayText [get, protected set]
 
bool isBackground [get, protected set]
 
bool hasAudio [get, protected set]
 
AC.Char speaker [get, protected set]
 
float TimeRemaining [get, set]
 
string SpeakerName [get]
 
int LineID [get]
 
string FullText [get]
 
SpeechLine SpeechLine [get]
 
int CurrentCharIndex [get]
 
string OriginalText [get]
 

Detailed Description

A container class for an active line of dialogue.

Constructor & Destructor Documentation

◆ Speech() [1/2]

AC.Speech.Speech ( Char  _speaker,
string  _message,
int  lineID,
bool  _isBackground,
bool  _noAnimation,
bool  _preventSkipping = false,
AudioClip  audioOverride = null,
TextAsset  lipsyncOverride = null 
)

The default Constructor.

Parameters
_speakerThe speaking character. If null, the line is considered a narration
_messageThe subtitle text to display
lineIDThe unique ID number of the line, as generated by the Speech Manager
_isBackgroundTrue if the line should play in the background, and not interrupt Actions or gameplay
_noAnimationTrue if the speaking 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

◆ Speech() [2/2]

AC.Speech.Speech ( string  _message)

A special-case Constructor purely used to display text without tags when exporting script-sheets.

Parameters
_messageThe subtitle text to display

Member Function Documentation

◆ CanScroll()

bool AC.Speech.CanScroll ( )

Checks if scrolling is possible with this line - regardless of whether or not it is currently doing so

◆ EndBackgroundSpeechAudio()

void AC.Speech.EndBackgroundSpeechAudio ( AC.Char  newSpeaker)

Ends speech audio, if it is playing in the background.

Parameters
newSpeakerIf the line's speaker matches this, the audio will not end

◆ EndPause()

void AC.Speech.EndPause ( )

Ends the current pause.

◆ EndSpeechAudio()

void AC.Speech.EndSpeechAudio ( )

Ends speech audio, regardless of conditions.

◆ GetColour()

Color AC.Speech.GetColour ( )

Gets the colour of the subtitle text.

Returns
The colour of the subtitle text

◆ GetPortrait()

Texture AC.Speech.GetPortrait ( )

Gets the portrait graphic of the speaking character.

Returns
The speaking character's portrait graphic

◆ GetPortraitSprite()

Sprite AC.Speech.GetPortraitSprite ( )

Gets a Sprite based on the portrait graphic of the speaking character. If lipsincing is enabled, the sprite will be based on the current phoneme.

Returns
The speaking character's portrait sprite

◆ GetSpeaker()

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

Gets the display name of the speaking character.

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

◆ GetSpeakingCharacter()

AC.Char AC.Speech.GetSpeakingCharacter ( )

Gets the speaking character.

Returns
The speaking character

◆ HasConditions()

bool AC.Speech.HasConditions ( SpeechMenuLimit  speechMenuLimit,
SpeechMenuType  speechMenuType,
string  limitToCharacters,
SpeechProximityLimit  speechProximityLimit = SpeechProximityLimit.NoLimit,
float  speechProximityDistance = 0f 
)

Checks if the speech line matches certain conditions.

Parameters
speechMenuLimitWhat kind of speech has to play for this Menu to enable (All, BlockingOnly, BackgroundOnly)
speechMenuTypeWhat kind of speaker has to be speaking for this Menu to enable (All, CharactersOnly, NarrationOnly, SpecificCharactersOnly)
limitToCharactersA list of character names that this Menu will show for, if speechMenuType = SpeechMenuType.SpecificCharactersOnly
speechProximityLimitWhether or not the distance the Player/MainCamera is from the speaking character affects display
speechProximityDistanceThe maximum distance if speechProximityLimit != SpeechProximityLimit.NoLimit"
Returns
True if the speech line matches the conditions

◆ IsAnimating()

bool AC.Speech.IsAnimating ( )

Checks if the speaking character's portrait graphic can be animated.

Returns
True if the character's portrait graphic can be animated

◆ IsPaused()

bool AC.Speech.IsPaused ( )

Checks if the speech line is temporarily paused, due to a [wait] or [wait:X] token.

◆ IsPlayingAudio()

bool AC.Speech.IsPlayingAudio ( )

Checks if the speech line is currently playing audio

◆ IsScrolling()

bool AC.Speech.IsScrolling ( )

Checks if the speech line is currently scrolling

◆ MenuCanShow()

bool AC.Speech.MenuCanShow ( Menu  menu)

Checks if a Menu is able to show this speech line.

Parameters
menuThe Menu to check against
Returns
True if the Menu is able to show this speech line

◆ ReplaceDisplayText()

void AC.Speech.ReplaceDisplayText ( string  newDisplayText,
bool  resetScrollAmount = true 
)

Replaces the speech's display text. Note that this will not affect audio or lipsyncing

Parameters
newSpeechTextThe new display text
resetScrollAmountIf True, then the amount by which the text has scrolled will be reset

◆ SetCharIndex()

void AC.Speech.SetCharIndex ( int  charIndex)

Sets the scrolling amount to a specific character index. This will not affect the speech's duration, however.

Parameters
charIndexThe new character index

◆ UpdateDisplay()

void AC.Speech.UpdateDisplay ( )

Updates the state of the line. This is called every LateUpdate call by StateHandler.

◆ UpdateInput()

void AC.Speech.UpdateInput ( )

Updates the state of the Speech based on the user's input. This is called every Update call by StateHandler.

◆ UpdateVolume()

void AC.Speech.UpdateVolume ( )

Updates the speech volume to the level set in Options. This should be called whenever the Speech volume level is changed.

Member Data Documentation

◆ continueState

ContinueState AC.Speech.continueState = ContinueState.None

If not None, then the Action that ran this speech will end, but the speech line is still active

◆ isAlive

bool AC.Speech.isAlive

True if the line is active

◆ log

SpeechLog AC.Speech.log

The line's SpeechLog entry

◆ noAnimation

bool AC.Speech.noAnimation = false

If True, the assocaited character will not play speaking animation

Property Documentation

◆ CurrentCharIndex

int AC.Speech.CurrentCharIndex
get

The index of the current end of the line, if speech-scrolling is enabled in the Speech Manager

◆ displayText

string AC.Speech.displayText
getprotected set

The display text

◆ FullText

string AC.Speech.FullText
get

The full display text of the line

◆ hasAudio

bool AC.Speech.hasAudio
getprotected set

If True, the speech line has an AudioClip supplied

◆ isBackground

bool AC.Speech.isBackground
getprotected set

True if the line should play in the backround, and not interrupt Actions or gameplay.

◆ LineID

int AC.Speech.LineID
get

The ID number of the line, as set by the Speech Manager

◆ OriginalText

string AC.Speech.OriginalText
get

The original text, without stripping of tokens or tags

◆ speaker

AC.Char AC.Speech.speaker
getprotected set

The characters speaking the line, unless a narration

◆ SpeakerName

string AC.Speech.SpeakerName
get

The display name of the speaking character

◆ SpeechLine

SpeechLine AC.Speech.SpeechLine
get

The line's associated SpeechLine class, provided it's been gathered by the Speech Manager

◆ TimeRemaining

float AC.Speech.TimeRemaining
getset

The amount of time left of the Speech's lifetime