void LoadDatabase() { itemdb = ScriptableObject.CreateInstance <ItemDatabase>(); conddb = ScriptableObject.CreateInstance <AuraDatabase>(); perkdb = ScriptableObject.CreateInstance <PerkDatabase>(); skilldb = ScriptableObject.CreateInstance <SkillDatabase>(); npcdb = ScriptableObject.CreateInstance <NPCDatabase>(); factiondb = ScriptableObject.CreateInstance <FactionDatabase>(); itemdb.ReloadDatabase(); conddb.ReloadDatabase(); perkdb.ReloadDatabase(); skilldb.ReloadDatabase(); npcdb.ReloadDatabase(); factiondb.ReloadDatabase(); }
void LoadSkillDatabase() { skillDatabase = AssetDatabase.LoadAssetAtPath <SkillDatabase>(skillAssetPath); if (skillDatabase == null) { CreateSkillDatabase(); } if (skillDatabase.Skills == null) { skillDatabase.ReloadDatabase(); } else { EditorUtility.FocusProjectWindow(); Selection.activeObject = skillDatabase; } }
void OnGUI() { /* * Editor toolbar */ EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Create New Skill", GUILayout.Width(300))) { editorState = EditorState.Create; return; } if (GUILayout.Button("Reload Database", GUILayout.Width(300))) { skillDatabase.ReloadDatabase(); return; } if (GUILayout.Button("Save to JSON", GUILayout.Width(300))) { // Delete this item from the database. skillDatabase.SaveDatabase(); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } EditorGUILayout.EndHorizontal(); if (skillDatabase == null || skillDatabase.Skills == 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 (Skill i in skillDatabase.Skills) { // Horizontal group per condition. EditorGUILayout.BeginHorizontal(GUILayout.Width(400.0f)); if (GUILayout.Button("X", GUILayout.Width(50.0f))) { // Delete this item from the database. skillDatabase.RemoveSkill(i); EditorUtility.SetDirty(skillDatabase); AssetDatabase.SaveAssets(); EditorUtility.FocusProjectWindow(); Selection.activeObject = skillDatabase; return; } if (GUILayout.Button(i.SkillName.ToString(), GUILayout.Width(350.0f))) { if (editorState == EditorState.Edit) { SaveExistingSkill(); } else if (editorState == EditorState.Create) { SaveNewSkill(); } //Get the new item and its associated data. selectedSkill = i; GetConditionData(); EditorUtility.FocusProjectWindow(); Selection.activeObject = skillDatabase; editorState = EditorState.Edit; return; } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndScrollView(); if (editorState == EditorState.Create || editorState == EditorState.Edit) { ShowCreateWindow(); } EditorGUILayout.EndHorizontal(); }