How to set DialogueSystemController.overrideGetLocalizedText to work with Dialogue Editor

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
preeda
Posts: 4
Joined: Thu May 02, 2024 6:38 am

How to set DialogueSystemController.overrideGetLocalizedText to work with Dialogue Editor

Post 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?
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to set DialogueSystemController.overrideGetLocalizedText to work with Dialogue Editor

Post 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
preeda
Posts: 4
Joined: Thu May 02, 2024 6:38 am

Re: How to set DialogueSystemController.overrideGetLocalizedText to work with Dialogue Editor

Post 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.
Attachments
Screenshot 2024-05-03 092535.png
Screenshot 2024-05-03 092535.png (9.01 KiB) Viewed 330 times
preeda
Posts: 4
Joined: Thu May 02, 2024 6:38 am

Re: How to set DialogueSystemController.overrideGetLocalizedText to work with Dialogue Editor

Post 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.
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to set DialogueSystemController.overrideGetLocalizedText to work with Dialogue Editor

Post 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);
}
preeda
Posts: 4
Joined: Thu May 02, 2024 6:38 am

Re: How to set DialogueSystemController.overrideGetLocalizedText to work with Dialogue Editor

Post 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]
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to set DialogueSystemController.overrideGetLocalizedText to work with Dialogue Editor

Post 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.
Post Reply