Page 1 of 1
How to set DialogueSystemController.overrideGetLocalizedText to work with Dialogue Editor
Posted: Thu May 02, 2024 6:51 am
by preeda
I have my localization method assigned to
Code: Select all
DialogueSystemController.overrideGetLocalizedText
but the localization setup from
Dialogue Editor doesn't call this delegate to get the localized text.
Do we have a way to make
Dialogue Editor get a localized text from the delegate function?
Re: How to set DialogueSystemController.overrideGetLocalizedText to work with Dialogue Editor
Posted: Thu May 02, 2024 7:55 am
by Tony Li
Hi,
What are you using to localize your text? DialogueSystemController.overrideGetLocalizedText is a runtime delegate; it won't work outside of play mode while you're editing in the Dialogue Editor. Maybe also related:
Localization
Re: How to set DialogueSystemController.overrideGetLocalizedText to work with Dialogue Editor
Posted: Thu May 02, 2024 10:29 pm
by preeda
I'm using a self-implemented system to localize the text that is assigned to DialogueSystemController.overrideGetLocalizedText in runtime but the data(Dialogue Text, Display Name) read from DialogueDatabase at runtime doesn't call my delegate function.
I tried another language called "LK" and switched to this language but the system only replaced the text from Dialogue Text with LK field, same for the default language
The value from "LK" field is a key that will get the localized text from my delegate function.
So I expected the value from "LK" or default if I didn't switch to "LK" to pass the value into the delegate function.
Re: How to set DialogueSystemController.overrideGetLocalizedText to work with Dialogue Editor
Posted: Thu May 02, 2024 10:29 pm
by preeda
I'm using a self-implemented system to localize the text that is assigned to DialogueSystemController.overrideGetLocalizedText in runtime but the data(Dialogue Text, Display Name) read from DialogueDatabase at runtime doesn't call my delegate function.
I tried another language called "LK" and switched to this language but the system only replaced the text from Dialogue Text with LK field, same for the default language
The value from "LK" field is a key that will get the localized text from my delegate function.
So I expected the value from "LK" or default if I didn't switch to "LK" to pass the value into the delegate function.
Re: How to set DialogueSystemController.overrideGetLocalizedText to work with Dialogue Editor
Posted: Thu May 02, 2024 10:46 pm
by Tony Li
DialogueSystemController.overrideGetLocalizedText only applies to non-dialogue text. If you want to localize dialogue text without using any of the Dialogue System's localization features, here are two approaches:
1. If you want to do it at edit-time, write an editor script that adds the localized fields to your database. For example (assuming your method is called GetTranslation(string) in this example):
Code: Select all
foreach (var conversation in database.conversations)
{
foreach (var entry in conversation.dialogueEntries)
{
Field.SetValue(entry.fields, "LK", GetTranslation(entry.DialogueText), FieldType.Localization);
}
}
EditorUtility.SetDirty(database);
2. If you want to do it at runtime, add a script with an OnConversationLine(Subtitle) method to your Dialogue Manager GameObject:
Code: Select all
void OnConversationLine(Subtitle subtitle)
{
subtitle.formattedText.text = GetTranslation(subtitle.formattedText.text);
}
Re: How to set DialogueSystemController.overrideGetLocalizedText to work with Dialogue Editor
Posted: Thu May 02, 2024 11:05 pm
by preeda
Thank you for the explanation,
In case I design to do it at runtime, does the text that replaces in OnConversationLine(Subtitle subtitle) will perform tags that control actor subtitle or else for example [panel=0] [picc=?] or should I do it at OnPrepareConversationLine instead.
example
key: character/character01-name-localization-key
value: Hello World! [panel=2]
Re: How to set DialogueSystemController.overrideGetLocalizedText to work with Dialogue Editor
Posted: Thu May 02, 2024 11:46 pm
by Tony Li
Hi,
Do it in OnConversationLine(Subtitle). By the time OnConversationLine runs, subtitle.formattedText.text will contain the text that the player will see, without markup tags.