Example #1
0
 void OnEnable()
 {
     if (EditorPrefs.HasKey("ObjectPath"))
     {
         string objectPath = EditorPrefs.GetString("ObjectPath");
         trackScriptable = AssetDatabase.LoadAssetAtPath(objectPath, typeof(TrackScriptable)) as TrackScriptable;
     }
 }
Example #2
0
    public static TrackScriptable Create()
    {
        TrackScriptable asset = ScriptableObject.CreateInstance <TrackScriptable>();

        Debug.Log("yolo");
        AssetDatabase.CreateAsset(asset, "Assets/Tracks/Track.asset");
        AssetDatabase.SaveAssets();
        return(asset);
    }
Example #3
0
 void CreateNewTrack()
 {
     // 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 ...
     viewIndex       = 1;
     trackScriptable = CreateTrack.Create();
     if (trackScriptable)
     {
         trackScriptable.chorusList = new List <ChorusScriptable>();
         string relPath = AssetDatabase.GetAssetPath(trackScriptable);
         EditorPrefs.SetString("ObjectPath", relPath);
     }
 }
Example #4
0
    void OpenTrack()
    {
        string absPath = EditorUtility.OpenFilePanel("Select Track", "", "");

        if (absPath.StartsWith(Application.dataPath))
        {
            string relPath = absPath.Substring(Application.dataPath.Length - "Assets".Length);
            trackScriptable = AssetDatabase.LoadAssetAtPath(relPath, typeof(TrackScriptable)) as TrackScriptable;
            if (trackScriptable.chorusList == null)
            {
                trackScriptable.chorusList = new List <ChorusScriptable>();
            }
            if (trackScriptable)
            {
                EditorPrefs.SetString("ObjectPath", relPath);
            }
        }
    }