Language Selector Popup

4 years 11 months ago #206 by Livealot
I modified the Popup selector provided in the example so that it would populate the popup list from languages in the editor and so that it would respect the current language rather than defaulting back to English. Upside is the popup list stays in synch with changes you make to the Language Source Editor. Downside is that it shows the user the full name of the languages (e.g., English (United States)). Hope this helps…

using UnityEngine;
using System.Collections;
using I2.Loc;

public class i2LangPopup : MonoBehaviour {

#if NGUI
void Start ()
UIPopupList mList = GetComponent<UIPopupList>();

//better to populate list from languages set up in Language Source Editor
foreach (string nextLang in LocalizationManager.GetAllLanguages()) {

EventDelegate.Add(mList.onChange, OnValueChange);

//this should be current language, not something static
mList.value = LocalizationManager.CurrentLanguage;

public void OnValueChange ()
LocalizationManager.CurrentLanguage = UIPopupList.current.value;

Please Log in or Create an account to join the conversation.

Time to create page: 1.162 seconds
Template by JoomlaShine