NGUI_LanguagePopup.cs 641 B

1234567891011121314151617181920212223242526272829
  1. using UnityEngine;
  2. // This class is an example of how to setup a Popup with all the languages in NGUI
  3. #if NGUI
  4. namespace I2.Loc
  5. {
  6. public class NGUI_LanguagePopup : MonoBehaviour
  7. {
  8. public LanguageSource Source;
  9. void Start ()
  10. {
  11. UIPopupList mList = GetComponent<UIPopupList>();
  12. mList.items = Source.mSource.GetLanguages();
  13. EventDelegate.Add(mList.onChange, OnValueChange);
  14. int idx = mList.items.IndexOf(LocalizationManager.CurrentLanguage);
  15. mList.value = mList.items[idx>=0 ? idx : 0];
  16. }
  17. public void OnValueChange ()
  18. {
  19. LocalizationManager.CurrentLanguage = UIPopupList.current.value;
  20. }
  21. }
  22. }
  23. #endif