add
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
//----------------------------------------------
|
||||
// NGUI: Next-Gen UI kit
|
||||
// Copyright © 2011-2015 Tasharen Entertainment
|
||||
//----------------------------------------------
|
||||
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
/// <summary>
|
||||
/// Turns the popup list it's attached to into a language selection list.
|
||||
/// </summary>
|
||||
|
||||
[RequireComponent(typeof(UIPopupList))]
|
||||
[AddComponentMenu("NGUI/Interaction/Language Selection")]
|
||||
public class LanguageSelection : MonoBehaviour
|
||||
{
|
||||
UIPopupList mList;
|
||||
|
||||
void Awake ()
|
||||
{
|
||||
mList = GetComponent<UIPopupList>();
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void Start () { EventDelegate.Add(mList.onChange, OnChange); } // modify by chenbin
|
||||
|
||||
#region add by chenbin
|
||||
void OnChange (GameObject go = null)
|
||||
{
|
||||
Localization.language = UIPopupList.current.value;
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Immediately refresh the list of known languages.
|
||||
/// </summary>
|
||||
|
||||
public void Refresh ()
|
||||
{
|
||||
if (mList != null && Localization.knownLanguages != null)
|
||||
{
|
||||
mList.items.Clear();
|
||||
|
||||
for (int i = 0, imax = Localization.knownLanguages.Length; i < imax; ++i)
|
||||
mList.items.Add(Localization.knownLanguages[i]);
|
||||
|
||||
mList.value = Localization.language;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user