private void Sections_OnAddCallback(ReorderableList l) { var section = new Section(); section.Name = GetUniqueName(sectionNames, "Section"); data.Sections.Insert(++l.index, section); keys.Insert(l.index, GetKeyList(data.Sections[l.index])); data.SyncPresets(); }
private void Load() { data = ModSettingsData.Make(SettingsPath); data.SaveDefaults(); data.LoadPresets(PresetPath); sections = new ReorderableList(data.Sections, typeof(SectionCollection), true, true, true, true); sections.drawHeaderCallback = Sections_DrawHeaderCallback; sections.drawElementCallback = Sections_DrawElementCallback; sections.elementHeightCallback = Sections_ElementHeightCallback; sections.onAddCallback = Sections_OnAddCallback; sections.onRemoveCallback = Sections_OnRemoveCallback; sections.onReorderCallback = Sections_OnReorderCallback; keys.Clear(); foreach (var section in data.Sections) { ReorderableList key = new ReorderableList(section.Keys, typeof(KeyCollection), true, true, true, true); key.drawHeaderCallback = Keys_DrawHeaderCallback; key.drawElementCallback = Keys_DrawElementCallback; key.elementHeightCallback = Keys_ElementHeightCallback; key.onAddCallback = Keys_OnAddCallback; key.onRemoveCallback = Keys_OnRemoveCallback; keys.Add(key); } presets = new ReorderableList(data.Presets, typeof(Preset), true, true, true, true); presets.drawHeaderCallback = r => presetsExpanded = EditorGUI.Foldout(r, presetsExpanded, "Presets"); presets.drawElementCallback = Presets_DrawElementCallback; presets.elementHeightCallback = x => presetsExpanded ? lineHeight : 0; currentPreset = -1; LoadPreset(-1); data.SyncPresets(); modName = Path.GetFileName(targetPath); localPath = GetLocalPath(targetPath); }