示例#1
0
        private static void AddFieldsToConfig()
        {
            foreach (FieldInfo field in _wrapperType.GetFields())
            {
                var attributes = field.GetCustomAttributes <ValueAttribute>(true);
                var locales    = field.GetCustomAttributes <LocaleAttribute>();

                foreach (ValueAttribute valueAttribute in attributes)
                {
                    Block block = GetBlock(valueAttribute.Name, "values");
                    var   item  = new Item {
                        name = field.Name
                    };

                    foreach (var locale in locales)
                    {
                        if (locale.I18n != null)
                        {
                            item.i18n = locale.I18n;
                            break;
                        }
                        else
                        {
                            if (locale.Strings.Length == 1)
                            {
                                item.SetLocale(locale.Code, locale.Strings[0]);
                            }
                            else
                            {
                                Debug.LogError("Property locale attribute must have 1 string");
                            }
                        }
                    }

                    block.AddItem(item);
                }
            }
        }