Esempio n. 1
0
 /// <summary>
 /// Load forbbiden texts.
 /// </summary>
 public static void LoadData()
 {
     if (FORMAT == EFormat.CSV)
     {
         string    path      = "Configs/fobbiden_word";
         TextAsset textAsset = Resources.Load(path) as TextAsset;
         if (textAsset == null)
         {
             Debug.LogError("[" + typeof(MyLocalizationManager).Name + "] LoadLanguage(): Could not find file \"" + path + "\"");
         }
         else
         {
             mForbiddenTexts = MyCSV.DeserializeByCell(textAsset.text).ToArray();
         }
     }
 }
        /// <summary>
        /// Load localization from csv file.
        /// </summary>
        private void _LoadLocalization()
        {
            if (Config.Location == ELocation.PERSISTENT)
            {
                if (!File.Exists(Application.persistentDataPath + Config.PersistentPath))
                {
                    Debug.LogError("[" + typeof(MyLocalizationManager).Name + "] Reload(): Could not find file \"" + (Application.persistentDataPath + Config.PersistentPath) + "\".");

                    TextAsset textAsset = Resources.Load(Config.ResourcesPath) as TextAsset;
                    if (textAsset == null)
                    {
                        Debug.LogError("[" + typeof(MyLocalizationManager).Name + "] Reload(): Could not find file \"" + Config.ResourcesPath + "\" too.");
                    }
                    else
                    {
                        mDictionary   = MyCSV.DeserializeByRowAndRowName(textAsset.text);
                        mLanguageKeys = mDictionary.First().Value;
                    }
                }
                else
                {
                    string text = File.ReadAllText(Application.persistentDataPath + Config.PersistentPath);
                    mDictionary   = MyCSV.DeserializeByRowAndRowName(text);
                    mLanguageKeys = mDictionary.First().Value;
                }
            }
            else
            {
                TextAsset textAsset = Resources.Load(Config.ResourcesPath) as TextAsset;
                if (textAsset == null)
                {
                    Debug.LogError("[" + typeof(MyLocalizationManager).Name + "] Reload(): Could not find file \"" + Config.ResourcesPath + "\".");
                }
                else
                {
                    mDictionary   = MyCSV.DeserializeByRowAndRowName(textAsset.text);
                    mLanguageKeys = mDictionary.First().Value;
                }
            }

            if (mLanguageKeys == null)
            {
                mLanguageKeys    = new string[1];
                mLanguageKeys[0] = Config.DefaultLanguage.ToString();
            }
        }