public Setting(FieldInfo field, SettingType type, string group) { Type = type; Name = field.Name; Group = group; DisplayNameAttribute.GetDisplayName(field, ref DisplayName); HelpTextAttribute.GetHelpText(field, ref HelpText); GroupAttribute.GetGroup(field, ref Group); UseAsShaderConstant = UseAsShaderConstantAttribute.UseFieldAsShaderConstant(field); }
public Setting(FieldInfo field, SettingType type, string group) { Type = type; Name = field.Name; Group = group; DisplayNameAttribute.GetDisplayName(field, ref DisplayName); HelpTextAttribute.GetHelpText(field, ref HelpText); GroupAttribute.GetGroup(field, ref Group); UseAsShaderConstant = UseAsShaderConstantAttribute.UseFieldAsShaderConstant(field); Visible = VisibleAttribute.IsVisible(field); Editable = EditableAttribute.IsEditable(field); VirtualCode = VirtualSettingAttribute.VirtualSettingCode(field); }
static void ReflectSettings(Assembly assembly, string inputFilePath, List <Setting> settings, List <Type> enumTypes, Dictionary <string, object> constants, List <SettingGroup> groups) { string filePath = Path.GetFileNameWithoutExtension(inputFilePath); Type settingsType = assembly.GetType(filePath + ".Settings", false); if (settingsType == null) { throw new Exception("Settings file " + inputFilePath + " doesn't define a \"Settings\" class"); } ReflectType(settingsType, settings, enumTypes, constants, ""); Type[] nestedTypes = settingsType.GetNestedTypes(); foreach (Type nestedType in nestedTypes) { string groupName = DisplayNameAttribute.GetDisplayName(nestedType); bool expandGroup = ExpandGroupAttribute.ExpandGroup(nestedType.GetTypeInfo()); groups.Add(new SettingGroup(groupName, expandGroup)); ReflectType(nestedType, settings, enumTypes, constants, groupName); } }