Switching between databases

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
EWalk13
Posts: 11
Joined: Mon Oct 12, 2015 6:20 pm

Switching between databases

Post by EWalk13 »

Hi, I am trying to create a game with two language options in it. What my idea was is to have two buttons when the game starts or on the pause menu, one says English and one says Spanish. I want to be able to click the button I want and have it set the Database I am using. For example I have an NPC and when you enter the trigger it will play the english verion, but then I would have a second conversation trigger on it and when the database is the spanish version then it will play the spanish text. Hope you can help!
EWalk13
Posts: 11
Joined: Mon Oct 12, 2015 6:20 pm

Re: Switching between databases

Post by EWalk13 »

I watched this tutorial https://www.youtube.com/watch?v=lG-k10t3Dz4, but I didn't work for me. I don't need to switch between scenes like in the video. I just want to be in one room and have the buttons switch the database for me. Then when I enter the NPC conversation after I press a button it will play the correct conversation trigger.
This is what I have in my script. Each function is attached to a button's OnClick, and they work when I start with no initial database and select a database to use, but when I try to switch to a new language it doesn't switch.
This is what I have in my script. Each function is attached to a button's OnClick, and they work when I start with no initial database and select a database to use, but when I try to switch to a new language it doesn't switch.
Language.PNG (22.15 KiB) Viewed 786 times
EWalk13
Posts: 11
Joined: Mon Oct 12, 2015 6:20 pm

Re: Switching between databases

Post by EWalk13 »

Never mind I figured it out. I had to change the order that I was adding and removing items.
User avatar
Tony Li
Posts: 21678
Joined: Thu Jul 18, 2013 1:27 pm

Re: Switching between databases

Post by Tony Li »

You don't need two separate databases for language localization. The Dialogue System has built-in localization within the same database.
To switch languages with UI buttons, add an OnClick script that calls DialogueManager.SetLanguage(). For example, change your SetSpanish() method to:

Code: Select all

public void SetSpanish()
{
    DialogueManager.SetLanguage("es"); // Or whatever you use to denote Spanish. ("es" is the .NET convention)
}
Post Reply