Quantcast
Channel: Questions in topic: "localization"
Viewing all articles
Browse latest Browse all 210

How to switch language in-game using official unity localization 0.9?

$
0
0
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 https://docs.unity3d.com/Packages/com.unity.localization@0.9/manual/index.html 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(); } 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?

Viewing all articles
Browse latest Browse all 210

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>