Author Topic: stackoverflow while broadcasting onlocalize message after setting a language  (Read 1380 times)

Lotti

  • Newbie
  • *
  • Thank You
  • -Given: 5
  • -Receive: 0
  • Posts: 47
    • View Profile
Hi! I updated to the latest ngui and now my game (already working with previous version of ngui) hangs on a stack overflow error (see attached log).

I'm still using the old way to load localization file (one file per language, with "key = value" syntax) and actually (since Localization went static) i have a static class (called Translate) that on initialization does this:

  1. public static init() {
  2.         Utils.setCultureInfo(CultureInfo.CurrentCulture);
  3.        
  4.         Localization.loadFunction = ( string path ) => {
  5.             byte[] bytes = null;
  6.             TextAsset asset = Resources.Load<TextAsset>("Languages/" + path);
  7.             if ( asset != null ) bytes = asset.bytes;
  8.             return bytes;
  9.         };
  10.         Localization.language = Application.systemLanguage;
  11. }
  12.  

I really don't know why it cause a stack overflow error :\

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Hmm. Change Localization.Set to:
  1.         static public void Set (string languageName, Dictionary<string, string> dictionary)
  2.         {
  3.                 mLanguage = languageName;
  4.                 PlayerPrefs.SetString("Language", mLanguage);
  5.                 mOldDictionary = dictionary;
  6.                 localizationHasBeenSet = true; // <-- this right here
  7.                 mLanguageIndex = -1;
  8.                 mLanguages = new string[] { languageName };
  9.                 if (onLocalize != null) onLocalize();
  10.                 UIRoot.Broadcast("OnLocalize");
  11.         }