void LoadData() { category = null; selectedCategoryIndex = -1; EditorHelpers.LoadCategoryConfigs(); EditorHelpers.LoadItemConfigs(); EditorHelpers.LoadCollectibleConfigs(); }
bool DrawLoadService() { contentColor = GUI.contentColor; backgroundColor = GUI.backgroundColor; EditorGUILayout.BeginHorizontal(); GUI.backgroundColor = EditorHelpers.orangeColor; if (GUILayout.Button("Load", GUILayout.Width(60))) { LoadData(); } GUI.backgroundColor = EditorHelpers.yellowColor; if (GUILayout.Button("New", GUILayout.Width(60))) { CategoryConfigData newData = new CategoryConfigData(); newData.id = "New Category " + newCategoryNameSufix.ToString(); ++newCategoryNameSufix; EditorHelpers.allCategories.Insert(0, newData); EditorHelpers.InitCategoryNames(); selectedCategoryIndex = 0; category = newData; ShowNotification(new GUIContent("New Category added.")); dirty = true; } GUI.backgroundColor = EditorHelpers.greenColor; if (GUILayout.Button("Save", GUILayout.Width(60))) { Save(); } GUI.backgroundColor = backgroundColor; EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); if (EditorHelpers.allCategories == null) { EditorGUILayout.HelpBox("It seems that there is no data... try reopening the editor.", MessageType.Error); return(false); } if (EditorHelpers.allCategories.Count > 0) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Categories:", GUILayout.Width(100)); int oldIntValue = selectedCategoryIndex; selectedCategoryIndex = EditorGUILayout.Popup(oldIntValue, EditorHelpers.categoryNames, GUILayout.Width(250)); if (oldIntValue != selectedCategoryIndex) { category = EditorHelpers.allCategories[selectedCategoryIndex]; } if (category != null) { GUI.backgroundColor = EditorHelpers.redColor; if (GUILayout.Button("Delete", GUILayout.Width(70))) { if (EditorUtility.DisplayDialog("Deleting Category!", "Are you sure you want to delete parameter '" + category.id + "'?", "Yes, Delete it.", "No!")) { EditorHelpers.gameDB.DeleteConfig(category.GetTableName(), category.id); EditorHelpers.allCategories.Remove(category); EditorHelpers.InitCategoryNames(); selectedCategoryIndex = -1; category = null; ShowNotification(new GUIContent("Category deleted.")); return(false); } } GUI.backgroundColor = backgroundColor; } EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.Separator(); } return(category != null); }