Creating a Language Localization button feature

I made 4 kind of language

The language changes when the button is clicked and the panel disappears when the x button is pressed.

For X Button FSM

Of course, you also need to create a button that opens the language settings when you click.

For setting Button FSM

I use a playmaker, but it’s a function that can be written simply with a script.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

using UnityEngine.Localization.Settings; 

public class LocalSelector : MonoBehaviour
{
	private bool active = false;
	public void ChangeLocale(int localeID)
	{
		if (active == true)
			return;
		StartCoroutine(SetLocale(localeID));
	}
	IEnumerator SetLocale(int _localeID)
	{
		active = true;
		yield return LocalizationSettings.InitializationOperation;
		LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.Locales[_localeID];
		active = false;
	}
}

There is no linguistic localization action in the playmaker. So I need to write a script for changing the language.

Put button in the country-specific image and connect the button and the script generated above

ex. In my case, it was Chinese 0 English 1 Japanese 2 Korean 3

I can’t see where Int is, so please test it according to the number of languages you set.

The language change function is working well.

Similar Posts