Page 1 of 1
Get localized conversation texts
Posted: Fri Sep 14, 2018 6:24 am
by fanaei
Hi
I wanna use Dialogue system as a localization system. So I want to get localized dialogue texts for buttons or other text based UIs in my game.
Can you help me that
how can I access the localized conversation texts?
- itTMP-problem2.jpg (126.28 KiB) Viewed 825 times
Re: Get localized conversation texts
Posted: Fri Sep 14, 2018 10:35 am
by fanaei
I found this way:
Code: Select all
public int ConversationID;
public int DialogueID;
void Start () {
GetComponent<RTLTextMeshPro>().text = DialogueManager.MasterDatabase.GetConversation(ConversationID).GetDialogueEntry(DialogueID).currentLocalizedDialogueText;
Debug.Log(DialogueManager.MasterDatabase.GetConversation(ConversationID).GetDialogueEntry(DialogueID).currentLocalizedDialogueText);
}
But when I use it with void Start, sometimes it gets null and if I put the code on Update, there won't be any problem. So what kind of void do you suggest to use?
Also I'm not sure if it's the best code to get the texts. And I wanted to know that is there any way to access the list of conversations and dialogues as a drop down list from my inspectore?
Re: Get localized conversation texts
Posted: Fri Sep 14, 2018 11:52 am
by Tony Li
Hi,
For conversations and quests, use localization inside the Dialogue Database asset.
For UI buttons and labels, use Text Table assets.
Here is the tutorial:
Localization Tutorial
Here is the manual page:
Localization
Re: Get localized conversation texts
Posted: Fri Sep 14, 2018 2:48 pm
by fanaei
Thank you Tony, but I still prefer not to use Text tables. Because using conversation panel is easier.
So just tell me why using
void Start gives me
null and with
void Update, I can get the right variable?
I don't wanna use Update, so I appreciate it if you tell me that what's the best void to use here?
Thanks
Code: Select all
void Start()
{
GetComponent<RTLTextMeshPro>().text =
DialogueManager.MasterDatabase.GetConversation(ConversationID).GetDialogueEntry(DialogueID).currentLocalizedDialogueText;
}
Re: Get localized conversation texts
Posted: Fri Sep 14, 2018 3:39 pm
by Tony Li
Okay. BTW, Text Tables are automatic. Assign the Text Table to the Dialogue Manager, and assign a Localize UI component to the UI element. The Localize UI component will automatically localize the label.
However, if you still want to use the dialogue database, give one frame for the Dialogue Manager's Start to run. For example:
Code: Select all
using System.Collections;
...
IEnumerator Start()
{
yield return new WaitForEndOfFrame();
GetComponent<RTLTextMeshPro>().text = DialogueManager.MasterDatabase.GetConversation(ConversationID).GetDialogueEntry(DialogueID).currentLocalizedDialogueText;
}