void OnEnable() { if (EditorPrefs.HasKey("ObjectPath")) { string objectPath = EditorPrefs.GetString("ObjectPath"); trackScriptable = AssetDatabase.LoadAssetAtPath(objectPath, typeof(TrackScriptable)) as TrackScriptable; } }
public static TrackScriptable Create() { TrackScriptable asset = ScriptableObject.CreateInstance <TrackScriptable>(); Debug.Log("yolo"); AssetDatabase.CreateAsset(asset, "Assets/Tracks/Track.asset"); AssetDatabase.SaveAssets(); return(asset); }
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); } }
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); } } }