示例#1
0
        private void FillData(Dictionary <string, object> dict, AssetBundle bundle, string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            LocalizationSourceAsset sourceAsset = bundle.LoadAsset <LocalizationSourceAsset>(path);

            if (sourceAsset == null)
            {
                return;
            }

            MonolingualSource source = sourceAsset.Source;

            if (source == null)
            {
                return;
            }

            foreach (KeyValuePair <string, object> kv in source.GetData())
            {
                dict[kv.Key] = kv.Value;
            }
        }
        private void FillData(Dictionary <string, object> dict, MonolingualSource source)
        {
            if (source == null)
            {
                return;
            }

            foreach (KeyValuePair <string, object> kv in source.GetData())
            {
                dict[kv.Key] = kv.Value;
            }
        }
        protected virtual async Task FillData(Dictionary <string, object> dict, IList <IResourceLocation> paths, CultureInfo cultureInfo)
        {
            try
            {
                if (paths == null || paths.Count <= 0)
                {
                    return;
                }

                var result = Addressables.LoadAssetsAsync <LocalizationSourceAsset>(paths, null);
                IList <LocalizationSourceAsset> assets = await result;
                this.handles.Add(result);
                foreach (LocalizationSourceAsset asset in assets)
                {
                    try
                    {
                        MonolingualSource source = asset.Source;
                        if (source == null)
                        {
                            continue;
                        }

                        foreach (KeyValuePair <string, object> kv in source.GetData())
                        {
                            dict[kv.Key] = kv.Value;
                        }
                    }
                    catch (Exception e)
                    {
                        if (log.IsWarnEnabled)
                        {
                            log.WarnFormat("An error occurred when loading localized data from \"{0}\".Error:{1}", asset.name, e);
                        }
                    }
                }
                Addressables.Release(result);
            }
            catch (Exception) { }
        }