I’m a newbie unity user who has never written a code before starting to learn unity couple weeks ago. Now i’m trying to learn how to implement a localization into game using official unity localization About Localization | Localization | 0.9.0-preview
I’ve more ol less succesfully assigned different string value for different languages using localization tables. Now i can switch language upon playing the game in editor. But how to switch it in game outside editor? I’ve tried to create a dropdown with a following script attached:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Localization;
using UnityEngine.Localization.Settings;
public class LanguageDropdown : MonoBehaviour
{
private Dropdown dropdown;
private string identifier;
void Start()
{
dropdown = GetComponent<Dropdown>();
}
void Update()
{
if (dropdown.value == 0)
{ identifier = "en"; }
else if (dropdown.value == 1)
{ identifier = "de"; }
else if (dropdown.value == 2)
{ identifier = "ru"; }
else if (dropdown.value == 3)
{ identifier = "uk"; }
SetLanguage(identifier);
}
void SetLanguage(string identifier)
{
Debug.Log("Selected language: " + identifier);
LocalizationSettings.SelectLocale(identifier);
}
}
The problem is that a method LocalizationSettings.SelectLocale(); which probably (i’m not sure) should switch current locale is inaccessible due to its protection level. It’s defined as protected virtual inside Unity LocalizationSettings class so i cannot access it. So what should i do considering that my scripting skills are very low at the moment?