public static ComboDataBase Create()
    {
        ComboDataBase asset = ScriptableObject.CreateInstance <ComboDataBase>();

        AssetDatabase.CreateAsset(asset, "Assets/ComboDataBase.asset");
        AssetDatabase.SaveAssets();
        return(asset);
    }
    public static ComboDataBase Create(DataBaseXML temp, ComboDataBase db)
    {
        ComboDataBase asset = ScriptableObject.CreateInstance <ComboDataBase>();

        asset.combos = temp.combos;
        AssetDatabase.CreateAsset(asset, "Assets/" + db + ".asset");
        AssetDatabase.SaveAssets();
        return(asset);
    }
Exemple #3
0
 void CreateNewDataBase()
 {
     // There is no overwrite protection here!
     // There is No "Are you sure you want to overwrite your existing object?" if it exists.
     // This should probably get a string from the user to create a new name and pass it ...
     db = CreateComboDataBase.Create(temp, db);
     if (db)
     {
         db.combos = new List <Combo>();
         string relPath = AssetDatabase.GetAssetPath(db);
         EditorPrefs.SetString("ObjectPath", relPath);
     }
     temp.combos = db.combos;
 }
Exemple #4
0
    void OnEnable()
    {
        if (temp == null)
        {
            temp = new DataBaseXML();
            if (EditorPrefs.HasKey("ObjectPath"))
            {
                string objectPath = EditorPrefs.GetString("ObjectPath");
                db = AssetDatabase.LoadAssetAtPath(objectPath, typeof(ComboDataBase)) as ComboDataBase;

                if (temp.combos == null)
                {
                    temp.combos = db.combos;
                }
            }
        }
    }
Exemple #5
0
    void OpenDataBase()
    {
        string absPath = EditorUtility.OpenFilePanel("Select Combo Database", "", "");

        if (absPath.StartsWith(Application.dataPath))
        {
            string relPath = absPath.Substring(Application.dataPath.Length - "Assets".Length);
            db = AssetDatabase.LoadAssetAtPath(relPath, typeof(ComboDataBase)) as ComboDataBase;
            if (db.combos == null)
            {
                db.combos = new List <Combo>();
            }
            if (db)
            {
                EditorPrefs.SetString("ObjectPath", relPath);
            }
            temp.combos = db.combos;
            Debug.Log("Load succesful.");
        }
    }
Exemple #6
0
 void SaveDataBase()
 {
     //save settings to database that's being edited rn
     db = CreateComboDataBase.Create(temp, db);
 }