Adventure Creator  1.74.2
An adventure game toolkit for Unity, by Chris Burton, ICEBOX Studios 2013-2019
AC.RuntimeLanguages Class Reference
Inheritance diagram for AC.RuntimeLanguages:

Public Member Functions

void OnInitPersistentEngine ()
 
virtual void LoadAssetBundle (int language)
 Loads in audio and lipsync AssetBundles for a given language More...
 
virtual AudioClip GetSpeechAudioClip (int lineID, Char _speaker)
 Gets the AudioClip associated with a speech line More...
 
virtual T GetSpeechLipsyncFile< T > (int lineID, Char _speaker)
 Gets the lipsync file associated with a speech line More...
 
string GetTranslation (string originalText, int _lineID, int language)
 Gets the translation of a line of text. More...
 
string GetTranslation (string originalText, int _lineID, int language, AC_TextType textType)
 Gets the translation of a line of text. More...
 
SpeechLine GetSpeechLine (string originalText, int _lineID, int language, AC_TextType textType)
 Gets the translation data for a line of text. More...
 
string GetCurrentLanguageText (int _lineID)
 Gets a line of text, translated (if applicable) to the current language. More...
 
string[] GetTranslations (int _lineID)
 Gets all translations of a line of text. More...
 
void UpdateRuntimeTranslation (int lineID, int languageIndex, string translationText)
 Updates the translation of a given line for a given language. More...
 
string GetTranslatableText (ITranslatable translatable, int index=0)
 Gets the text of an ITranslatable instance, based on the game's current language. More...
 
void ImportRuntimeTranslation (TextAsset textAsset, string languageName, int newTextColumn, bool ignoreEmptyCells=false, bool isRTL=false)
 Imports a translation CSV file (as generated by the Speech Manager) into the game - either as a new language, or as an update to an existing one. The first column MUST be the ID number of each line, and the first row must be for the header. More...
 
bool LanguageReadsRightToLeft (int languageIndex)
 Checks if a given language reads right-to-left, Hebrew/Arabic-style More...
 
bool LanguageReadsRightToLeft (string languageName)
 Checks if a given language reads right-to-left, Hebrew/Arabic-style More...
 
bool MarkLineAsSpoken (int lineID)
 Marks a speech line as having been spoken, so that it cannot be spoken again. This will only work for speech lines that have 'Can only play once?' checked in their Speech Manager entry. More...
 
MainData SaveMainData (MainData mainData)
 Updates a MainData class with its own variables that need saving. More...
 
void LoadMainData (MainData mainData)
 Updates its own variables from a MainData class. More...
 

Protected Member Functions

void TransferFromManager ()
 
IEnumerator LoadAssetBundleCoroutine (int i)
 
AudioClip GetLineCustomAudioClip (int _lineID, int _language=0)
 
UnityEngine.Object GetLineCustomLipsyncFile (int _lineID, int _language=0)
 
void CreateLanguage (string name, bool isRTL)
 
void ProcessTranslationFile (int i, string csvText, int newTextColumn, bool ignoreEmptyCells)
 
string AddLineBreaks (string text)
 

Protected Attributes

Dictionary< int, SpeechLinespeechLinesDictionary = new Dictionary<int, SpeechLine>()
 
List< string > languages = new List<string>()
 
List< bool > languageIsRightToLeft = new List<bool>()
 
List< string > languageAudioAssetBundles = new List<string>()
 
List< string > languageLipsyncAssetBundles = new List<string>()
 
AssetBundle currentAudioAssetBundle = null
 
string currentAudioAssetBundleName
 
AssetBundle currentLipsyncAssetBundle = null
 
string currentLipsyncAssetBundleName
 
bool isLoadingBundle
 
List< int > spokenOnceSpeechLineIDs = new List<int>()
 

Properties

AssetBundle CurrentAudioAssetBundle [get, set]
 
AssetBundle CurrentLipsyncAssetBundle [get, set]
 
List< string > Languages [get]
 
bool IsLoadingBundle [get]
 

Detailed Description

This script contains all language data for the game at runtime. It transfers data from the Speech Manaager to itself when the game begins.

Member Function Documentation

◆ GetCurrentLanguageText()

string AC.RuntimeLanguages.GetCurrentLanguageText ( int  _lineID)

Gets a line of text, translated (if applicable) to the current language.

Parameters
_lineIDThe translation ID number generated by SpeechManager's PopulateList() function
Returns
A line of text, translated (if applicable) to the current language.</returnsy>

◆ GetSpeechAudioClip()

virtual AudioClip AC.RuntimeLanguages.GetSpeechAudioClip ( int  lineID,
Char  _speaker 
)
virtual

Gets the AudioClip associated with a speech line

Parameters
lineIDThe ID number of the speech line, as generated by the Speech Manager
_speakerThe character speaking the line
Returns
Gets the AudioClip associated with a speech line

◆ GetSpeechLine()

SpeechLine AC.RuntimeLanguages.GetSpeechLine ( string  originalText,
int  _lineID,
int  language,
AC_TextType  textType 
)

Gets the translation data for a line of text.

Parameters
originalTextThe line in its original language.
_lineIDThe translation ID number generated by SpeechManager's PopulateList() function
languageThe index number of the language to return the line in, where 0 = the game's original language.
textTypeThe type of text to translatable.
Returns
The translation data of the line, if it exists. If a translation does not exist, or the given textType is not translatable, then null will be returned.

◆ GetSpeechLipsyncFile< T >()

virtual T AC.RuntimeLanguages.GetSpeechLipsyncFile< T > ( int  lineID,
Char  _speaker 
)
virtual

Gets the lipsync file associated with a speech line

Parameters
lineIDThe ID number of the speech line, as generated by the Speech Manager
_speakerThe character speaking the line
Returns
Gets the lipsync file associated with a speech line
Type Constraints
T :Object 

◆ GetTranslatableText()

string AC.RuntimeLanguages.GetTranslatableText ( ITranslatable  translatable,
int  index = 0 
)

Gets the text of an ITranslatable instance, based on the game's current language.

Parameters
translatableThe ITranslatable instance.
indexThe index of the ITranslatable's array of translatable text
Returns
The translatable text.

◆ GetTranslation() [1/2]

string AC.RuntimeLanguages.GetTranslation ( string  originalText,
int  _lineID,
int  language 
)

Gets the translation of a line of text.

Parameters
originalTextThe line in its original language.
_lineIDThe translation ID number generated by SpeechManager's PopulateList() function
languageThe index number of the language to return the line in, where 0 = the game's original language.
Returns
The translation of the line, if it exists. If a translation does not exist, then the original line will be returned.

◆ GetTranslation() [2/2]

string AC.RuntimeLanguages.GetTranslation ( string  originalText,
int  _lineID,
int  language,
AC_TextType  textType 
)

Gets the translation of a line of text.

Parameters
originalTextThe line in its original language.
_lineIDThe translation ID number generated by SpeechManager's PopulateList() function
languageThe index number of the language to return the line in, where 0 = the game's original language.
textTypeThe type of text to translatable.
Returns
The translation of the line, if it exists. If a translation does not exist, or the given textType is not translatable, then the original line will be returned.

◆ GetTranslations()

string [] AC.RuntimeLanguages.GetTranslations ( int  _lineID)

Gets all translations of a line of text.

Parameters
_lineIDThe translation ID number generated by SpeechManager's PopulateList() function
Returns
All translations of the line, if they exist. If a translation does not exist, nothing will be returned.

◆ ImportRuntimeTranslation()

void AC.RuntimeLanguages.ImportRuntimeTranslation ( TextAsset  textAsset,
string  languageName,
int  newTextColumn,
bool  ignoreEmptyCells = false,
bool  isRTL = false 
)

Imports a translation CSV file (as generated by the Speech Manager) into the game - either as a new language, or as an update to an existing one. The first column MUST be the ID number of each line, and the first row must be for the header.

Parameters
textAssetThe CSV file as a text asset.
languageNameThe name of the language. If a language by this name already exists in the system, the import process will update it.
newTextColumnThe column number (starting from zero) that holds the new translation. This must be greater than zero, as the first column should be occupied by the ID numbers.
ignoreEmptyCellsIf True, then empty cells will not be imported and the original language will be used instead
isRTLIf True, the language is read right-to-left

◆ LanguageReadsRightToLeft() [1/2]

bool AC.RuntimeLanguages.LanguageReadsRightToLeft ( int  languageIndex)

Checks if a given language reads right-to-left, Hebrew/Arabic-style

Parameters
languageIndexThe index number of the language to check, where 0 is the game's original language
Returns
True if the given language reads right-to-left

◆ LanguageReadsRightToLeft() [2/2]

bool AC.RuntimeLanguages.LanguageReadsRightToLeft ( string  languageName)

Checks if a given language reads right-to-left, Hebrew/Arabic-style

Parameters
languageNameThe name of the language to check, as written in the Speech Manager
Returns
True if the given language reads right-to-left

◆ LoadAssetBundle()

virtual void AC.RuntimeLanguages.LoadAssetBundle ( int  language)
virtual

Loads in audio and lipsync AssetBundles for a given language

Parameters
languageThe index number of the language to load AssetBundles for

◆ LoadMainData()

void AC.RuntimeLanguages.LoadMainData ( MainData  mainData)

Updates its own variables from a MainData class.

Parameters
mainDataThe MainData class to load from

◆ MarkLineAsSpoken()

bool AC.RuntimeLanguages.MarkLineAsSpoken ( int  lineID)

Marks a speech line as having been spoken, so that it cannot be spoken again. This will only work for speech lines that have 'Can only play once?' checked in their Speech Manager entry.

Parameters
lineIDThe line being spoken
Returns
True if the line can be spoken, False if it has already been spoken and cannot be spoken again.

◆ SaveMainData()

MainData AC.RuntimeLanguages.SaveMainData ( MainData  mainData)

Updates a MainData class with its own variables that need saving.

Parameters
mainDataThe original MainData class
Returns
The updated MainData class

◆ UpdateRuntimeTranslation()

void AC.RuntimeLanguages.UpdateRuntimeTranslation ( int  lineID,
int  languageIndex,
string  translationText 
)

Updates the translation of a given line for a given language.

Parameters
lineIDThe ID of the text to update, as generated by the Speech Manager
languageIndexThe index number of the language to update. Must be greater than 0, since 0 is the game's original language
translationTextThe updated translation text

Property Documentation

◆ CurrentAudioAssetBundle

AssetBundle AC.RuntimeLanguages.CurrentAudioAssetBundle
getset

The AssetBundle to retrieve audio files from

◆ CurrentLipsyncAssetBundle

AssetBundle AC.RuntimeLanguages.CurrentLipsyncAssetBundle
getset

The AssetBundle to retrieve lipsync files from

◆ IsLoadingBundle

bool AC.RuntimeLanguages.IsLoadingBundle
get

True if an audio or lipsync asset bundle is currently being loaded into memory

◆ Languages

List<string> AC.RuntimeLanguages.Languages
get

The names of the game's languages. The first is always "Original".