Esempio n. 1
0
        private void ReadCSVMPK()
        {
            if (LanguagesCSVFiles.Count <= 0)
            {
                return;
            }

            //根据当前已读的配置先加载
            if (LocalizeDataTable != null)
            {
                List <string> LoadedFiles = LocalizeDataTable.Select(d => d.Key).ToList();
                LocalizeDataTable = new Dictionary <string, Dictionary <string, Dictionary <string, string> > >();

                foreach (string loadedFile in LoadedFiles)
                {
                    ReadCSVMPKFile(loadedFile);
                }
            }
            else
            {
                LocalizeDataTable = new Dictionary <string, Dictionary <string, Dictionary <string, string> > >();
            }

            //编辑模式下都加载
#if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                foreach (string file in LanguagesCSVFiles)
                {
                    ReadCSVMPKFile(file);
                }
            }
#endif
        }
Esempio n. 2
0
        /// <summary>
        /// 当前语言改变时,根据重新加载事件读取所有语言配置文件路径
        /// </summary>
        private void ReadCSVFolder()
        {
            DirectoryInfo rootDirInfo;

            //根据当前语言版本获取语言文件根目录

            if (GameLogicConfigApi.LanguageDirName != string.Empty && Application.isPlaying)
            {
                rootDirInfo = new DirectoryInfo(ViewConfigManager.DataScpPath + "UI/");
            }
            else
            {
                string path = ViewConfigManager.DataScpPath;
                if (GameLogicConfigApi.LanguageDirName != string.Empty)
                {
                    int index = ViewConfigManager.DataScpPath.LastIndexOf(GameLogicConfigApi.LanguageDirName);
                    path = ViewConfigManager.DataScpPath.Substring(0, index);
                }


                rootDirInfo = new DirectoryInfo(path + Language.Name + "/UI/");
            }



            if (rootDirInfo == null || !rootDirInfo.Exists)
            {
                UnityEngine.Debug.LogError("没找到语言文件夹:" + Language.Name);
                return;
            }
            //遍历该目录下所有csv文件
            allCSVFiles = rootDirInfo.GetFiles("*.csv");
            if (allCSVFiles.Length == 0)
            {
                UnityEngine.Debug.LogError(Language.Name + "文件夹下没有csv配置文件...");
                return;
            }

            //根据当前已读的配置先加载
            if (LocalizeDataTable != null)
            {
                List <string> LoadedFiles = LocalizeDataTable.Select(d => d.Key).ToList();
                LocalizeDataTable = new Dictionary <string, Dictionary <string, Dictionary <string, string> > >();

                foreach (string loadedFile in LoadedFiles)
                {
                    ReadCSVFile(loadedFile);
                }
            }
            else
            {
                LocalizeDataTable = new Dictionary <string, Dictionary <string, Dictionary <string, string> > >();
            }

            //编辑模式下都加载
#if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                foreach (FileInfo file in allCSVFiles)
                {
                    ReadCSVFile(file);
                }
            }
#endif
        }