public void SetConfigType(ConfigBase <T> tp) { this.config_current = tp; configSetting = ConfigEditorAttribute.GetCurrentAttribute <ConfigEditorAttribute>(tp); this.titleContent = new GUIContent(string.IsNullOrEmpty(configSetting.EditorTitle) ? typeof(T).Name : configSetting.EditorTitle); fieldinfos = typeof(T).GetFields().ToList(); Chache = new List <ConfigEditorSchemaChache>(); foreach (var item in fieldinfos) { var infos = item.GetCustomAttributes(typeof(ConfigEditorFieldAttribute), true); ConfigEditorSchemaChache f = new ConfigEditorSchemaChache(); f.field_info = item; f.order = 0; if (infos.Length == 0) { continue; } else { ConfigEditorFieldAttribute cefa = (ConfigEditorFieldAttribute)infos[0]; f.order = cefa.Order; f.config_editor_field = cefa; } Chache.Add(f); } if (Chache.Count > 0) { Chache = Chache.OrderByDescending(x => x.order).ToList(); } initialized = true; }
public void SetConfigType(ConfigBase <T> tp) { this.config_current = tp; configSetting = ConfigEditorAttribute.GetCurrentAttribute <ConfigEditorAttribute>(tp) ?? new ConfigEditorAttribute(); this.titleContent = new GUIContent(string.IsNullOrEmpty(configSetting.Setting.EditorTitle) ? typeof(T).Name : configSetting.Setting.EditorTitle); fieldinfos = typeof(T).GetFields().ToList(); Chache = new List <ConfigEditorSchemaChache>(); foreach (var item in fieldinfos) { var infos = item.GetCustomAttributes(typeof(ConfigEditorFieldAttribute), true); ConfigEditorSchemaChache f = new ConfigEditorSchemaChache(); f.field_info = item; f.order = 0; if (infos.Length == 0) { int id = (int)GetCurrentFieldType(item.FieldType); f.config_editor_setting = Utility.GetDefaultControlConfig().SearchByID(id); if (f.config_editor_setting == null) { Log("Can't find default control id :" + id); } else { if (!f.config_editor_setting.Visibility) { continue; } } } else { ConfigEditorFieldAttribute cefa = (ConfigEditorFieldAttribute)infos[0]; f.order = cefa.Setting.Order; f.config_editor_setting = cefa.Setting; if (f.config_editor_setting.Width == 0) { int id = (int)GetCurrentFieldType(item.FieldType); var setting = Utility.GetDefaultControlConfig().SearchByID(id); f.config_editor_setting.Width = setting.Width; } if (!cefa.Setting.Visibility) { continue; } } Chache.Add(f); } if (Chache.Count > 0) { Chache = Chache.OrderByDescending(x => x.order).ToList(); } initialized = true; }