void OnEnable() { if (EditorPrefs.HasKey("ObjectPath")) { string objectPath = EditorPrefs.GetString("ObjectPath"); _levelList = AssetDatabase.LoadAssetAtPath(objectPath, typeof(LevelList)) as LevelList; } }
public static LevelList Create() { LevelList asset = ScriptableObject.CreateInstance <LevelList>(); AssetDatabase.CreateAsset(asset, "Assets/LevelList.asset"); AssetDatabase.SaveAssets(); return(asset); }
void CreateNewLevelList() { _viewIndex = 1; _levelList = CreateLevelList.Create(); if (_levelList) { _levelList.levels = new List <LevelData>(); string relPath = AssetDatabase.GetAssetPath(_levelList); EditorPrefs.SetString("ObjectPath", relPath); } }
void OpenLevelList() { string absPath = EditorUtility.OpenFilePanel("Select Level List", "", ""); if (absPath.StartsWith(Application.dataPath)) { string relPath = absPath.Substring(Application.dataPath.Length - "Assets".Length); _levelList = AssetDatabase.LoadAssetAtPath(relPath, typeof(LevelList)) as LevelList; if (_levelList.levels == null) { _levelList.levels = new List <LevelData>(); } if (_levelList) { EditorPrefs.SetString("ObjectPath", relPath); } } }