Get localized conversation texts

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
fanaei
Posts: 73
Joined: Wed Aug 15, 2018 10:38 am

Get localized conversation texts

Post 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
itTMP-problem2.jpg (126.28 KiB) Viewed 822 times
fanaei
Posts: 73
Joined: Wed Aug 15, 2018 10:38 am

Re: Get localized conversation texts

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

Re: Get localized conversation texts

Post 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
fanaei
Posts: 73
Joined: Wed Aug 15, 2018 10:38 am

Re: Get localized conversation texts

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

Re: Get localized conversation texts

Post 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;
}
Post Reply