文档:Quick Start Guide | Localization | 1.2.1 (unity3d.com)
/****************************************************
文件:LocaleSelector.cs
作者:Edision
日期:#CreateTime#
功能:语言本地化
*****************************************************/
using System.Collections;
using UnityEngine;
using UnityEngine.Localization.Settings;
public class LocaleSelector : MonoBehaviour
{
private bool active = false;
private void Start()
{
int ID = PlayerPrefs.GetInt("LocaleKey", 0);
ChangeLocale(ID);
}
public void ChangeLocale(int localeID)
{
if (!active)
{
StartCoroutine(SetLocale(localeID));
}
}
private IEnumerator SetLocale(int _localID)
{
active = true;
yield return LocalizationSettings.InitializationOperation;
LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.Locales[_localID];
PlayerPrefs.SetInt("LocaleKey", _localID);
active = false;
}
}