コード例 #1
0
    void LoadAuxillaryDatabases()
    {
        // CONDITION database
        _conditionDatabase = AssetDatabase.LoadAssetAtPath <AuraDatabase>(conditionPath);
        if (_conditionDatabase.Auras == null)
        {
            _conditionDatabase.ReloadDatabase();
        }

        // PERK database
        _perkDatabase = AssetDatabase.LoadAssetAtPath <PerkDatabase>(perkAssetPath);
        _perkDatabase.ReloadDatabase();
    }
コード例 #2
0
    void LoadPerkDatabase()
    {
        perkDatabase = AssetDatabase.LoadAssetAtPath <PerkDatabase>(perkAssetPath);
        perkDatabase.ReloadDatabase();

        if (perkDatabase == null)
        {
            CreatePerkDatabase();
        }
        else
        {
            AssetDatabase.SaveAssets();
            EditorUtility.FocusProjectWindow();
            Selection.activeObject = perkDatabase;
        }
    }
コード例 #3
0
    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();
    }
コード例 #4
0
    void OnGUI()
    {
        /*
         * Editor Toolbar
         */
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Create New Perk", GUILayout.Width(300)))
        {
            editorState = EditorState.Create;
            return;
        }
        if (GUILayout.Button("Reload Database", GUILayout.Width(300)))
        {
            perkDatabase.ReloadDatabase();
            return;
        }
        if (GUILayout.Button("Save to JSON", GUILayout.Width(300)))
        {
            // Delete this perk from the database.
            perkDatabase.SaveDatabase();
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
        }
        EditorGUILayout.EndHorizontal();

        if (perkDatabase == null || perkDatabase.Perks == 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 (Perk i in perkDatabase.Perks)
        {
            // Horizontal group per perk.
            EditorGUILayout.BeginHorizontal(GUILayout.Width(400.0f));

            if (GUILayout.Button("X", GUILayout.Width(50.0f)))
            {
                // Delete this item from the database.
                perkDatabase.RemovePerk(i);
                EditorUtility.SetDirty(perkDatabase);
                AssetDatabase.SaveAssets();
                EditorUtility.FocusProjectWindow();
                Selection.activeObject = perkDatabase;
                return;
            }

            if (GUILayout.Button("C", GUILayout.Width(50.0f)))
            {
                // Duplicate this item.
                perkDatabase.DuplicatePerk(i);
                EditorUtility.SetDirty(perkDatabase);
                AssetDatabase.SaveAssets();
                EditorUtility.FocusProjectWindow();
                Selection.activeObject = perkDatabase;
                return;
            }

            if (GUILayout.Button(i.PerkName.ToString(), GUILayout.Width(300)))
            {
                if (editorState == EditorState.Edit)
                {
                    SaveExistingPerk();
                }
                else if (editorState == EditorState.Create)
                {
                    SaveNewPerk();
                }

                //Get the new item and its associated data.
                selectedPerk = i;
                GetPerkData();
                AssetDatabase.SaveAssets();
                EditorUtility.FocusProjectWindow();
                Selection.activeObject = perkDatabase;

                editorState = EditorState.Edit;

                return;
            }

            EditorGUILayout.EndHorizontal();
        }
        EditorGUILayout.EndScrollView();

        if (editorState == EditorState.Create || editorState == EditorState.Edit)
        {
            ShowCreateWindow();
        }

        EditorGUILayout.EndHorizontal();
    }
コード例 #5
0
 void LoadAuxillaryDatabases()
 {
     // PERK database
     _perkDatabase = AssetDatabase.LoadAssetAtPath <PerkDatabase>(perkAssetPath);
     _perkDatabase.ReloadDatabase();
 }
コード例 #6
0
    void OnGUI()
    {
        /*
         * Editor toolbar.
         */
        // Button row.
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Create New Item", GUILayout.Width(300.0f)))
        {
            // Create a new item...
            editorState = EditorState.Create;
            return;
        }
        if (GUILayout.Button("Reload Database", GUILayout.Width(300.0f)))
        {
            itemDatabase.ReloadDatabase();
            _conditionDatabase.ReloadDatabase();
            _perkDatabase.ReloadDatabase();
            return;
        }
        if (GUILayout.Button("Save to JSON", GUILayout.Width(300)))
        {
            // Delete this item from the database.
            itemDatabase.SaveDatabase();
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
        }
        EditorGUILayout.EndHorizontal();

        // Filter row.
        EditorGUILayout.BeginHorizontal();
        filterType       = (ItemType)EditorGUILayout.EnumPopup("Show Type: ", filterType);
        filterTypeToggle = EditorGUILayout.Toggle(filterTypeToggle);
        EditorGUILayout.EndHorizontal();

        // Kill the script before a null pointer exception is thrown (ugh why).
        if (itemDatabase == null || itemDatabase.Items == 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 (GameItem i in itemDatabase.Items)
        {
            // Filter if necessary.
            if (filterTypeToggle)
            {
                if (i.ItemType != filterType)
                {
                    continue;
                }
            }

            // Horizontal group per item.
            EditorGUILayout.BeginHorizontal(GUILayout.Width(400));

            if (GUILayout.Button("X", GUILayout.Width(50.0f)))
            {
                // Delete this item from the database.
                itemDatabase.RemoveItem(i);
                EditorUtility.SetDirty(itemDatabase);
                AssetDatabase.SaveAssets();
                EditorUtility.FocusProjectWindow();
                Selection.activeObject = itemDatabase;
                return;
            }

            if (GUILayout.Button("C", GUILayout.Width(50.0f)))
            {
                // Duplicate this item.
                itemDatabase.DuplicateItem(i);
                EditorUtility.SetDirty(itemDatabase);
                AssetDatabase.SaveAssets();
                EditorUtility.FocusProjectWindow();
                Selection.activeObject = itemDatabase;
                return;
            }

            if (GUILayout.Button(i.ItemName.ToString(), GUILayout.Width(300)))
            {
                if (editorState == EditorState.Edit)
                {
                    SaveExistingItem(selectedItem.ItemType);
                }
                else if (editorState == EditorState.Create)
                {
                    SaveNewItem(itemType);
                }

                //Get the new item and its associated data.
                selectedItem = i;
                GetItemData();
                EditorUtility.FocusProjectWindow();
                Selection.activeObject = itemDatabase;

                editorState = EditorState.Edit;

                return;
            }

            EditorGUILayout.EndHorizontal();
        }
        EditorGUILayout.EndScrollView();

        if (editorState == EditorState.Create || editorState == EditorState.Edit)
        {
            ShowCreateWindow();
        }

        EditorGUILayout.EndHorizontal();
    }