void OnGUI() { /* * Editor toolbar */ EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Create New Quest", GUILayout.Width(300))) { editorState = EditorState.Create; return; } if (GUILayout.Button("Reload Database", GUILayout.Width(300))) { questDatabase.ReloadDatabase(); return; } if (GUILayout.Button("Save to JSON", GUILayout.Width(300))) { // Delete this item from the database. questDatabase.SaveDatabase(); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } EditorGUILayout.EndHorizontal(); if (questDatabase == null || questDatabase.Quests == null) { EditorGUILayout.LabelField("The database may need reloading."); return; } EditorGUILayout.BeginHorizontal(); // List all of the items on the left hand side. listScrollPos = EditorGUILayout.BeginScrollView(listScrollPos, false, false, GUILayout.Width(450), GUILayout.MinHeight(550)); foreach (Quest i in questDatabase.Quests) { // Horizontal group per condition. EditorGUILayout.BeginHorizontal(GUILayout.Width(400.0f)); if (GUILayout.Button("X", GUILayout.Width(50.0f))) { // Delete this item from the database. questDatabase.RemoveQuest(i); EditorUtility.SetDirty(questDatabase); AssetDatabase.SaveAssets(); EditorUtility.FocusProjectWindow(); Selection.activeObject = questDatabase; return; } if (GUILayout.Button("C", GUILayout.Width(50.0f))) { // Duplicate this item. questDatabase.DuplicateQuest(i); EditorUtility.SetDirty(questDatabase); AssetDatabase.SaveAssets(); EditorUtility.FocusProjectWindow(); Selection.activeObject = questDatabase; return; } if (GUILayout.Button(i.QuestName.ToString(), GUILayout.Width(300))) { if (editorState == EditorState.Edit) { SaveExistingQuest(); } else if (editorState == EditorState.Create) { SaveNewQuest(); } //Get the new item and its associated data. selectedQuest = i; GetQuestData(); if (selectedQuest.QuestStages.Count > 0) { showQuestStages = true; } EditorUtility.FocusProjectWindow(); Selection.activeObject = questDatabase; editorState = EditorState.Edit; return; } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndScrollView(); if (editorState == EditorState.Create || editorState == EditorState.Edit) { ShowCreateWindow(); } EditorGUILayout.EndHorizontal(); }