Exemple #1
0
        /// <summary>
        /// 枚举所有可用的语言文件;文件命名需要符合要求;
        /// </summary>
        public static IEnumerable <LanguagePackInfo> Enumerate(this LanguagePackSerializer packSerializer, Content content, string rootDirectory, SearchOption searchOption)
        {
            if (packSerializer == null)
            {
                throw new ArgumentNullException(nameof(packSerializer));
            }
            if (content == null)
            {
                throw new ArgumentNullException(nameof(content));
            }

            foreach (string entry in content.EnumerateFiles(rootDirectory, LanguagePackFileSearchPattern, searchOption))
            {
                LanguagePackInfo languagePack;
                try
                {
                    using (var stream = content.GetInputStream(entry))
                    {
                        var description = packSerializer.Deserialize(stream);
                        languagePack = new LanguagePackInfo(description, content, entry);
                    }
                }
                catch (Exception ex)
                {
                    UnityEngine.Debug.Log(ex);
                    languagePack = null;
                }

                if (languagePack != null)
                {
                    yield return(languagePack);
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// 枚举所有可用的语言文件;文件命名需要符合要求;
        /// </summary>
        public IEnumerable <LanguagePackInfo> EnumeratePack(Content contentConstruct, SearchOption searchOption)
        {
            foreach (string entry in contentConstruct.EnumerateFiles(LocalizationDirectoryName, LanguagePackFileSearchPattern, searchOption))
            {
                LanguagePackInfo languagePack;
                try
                {
                    using (var stream = contentConstruct.GetInputStream(entry))
                    {
                        var description = packSerializer.Deserialize(stream);
                        languagePack = new LanguagePackInfo(description, contentConstruct, entry);
                    }
                }
                catch (Exception ex)
                {
                    UnityEngine.Debug.Log(ex);
                    languagePack = null;
                }

                if (languagePack != null)
                {
                    yield return(languagePack);
                }
            }
        }