public static CharacterJobList Create() { CharacterJobList asset = ScriptableObject.CreateInstance <CharacterJobList>(); AssetDatabase.CreateAsset(asset, "Assets/Scripts/Characters/JobScript/CharacterJobList.asset"); AssetDatabase.SaveAssets(); return(asset); }
void OnEnable() { if (EditorPrefs.HasKey("ObjectPath")) { string objectPath = EditorPrefs.GetString("ObjectPath"); CharacterJobList = AssetDatabase.LoadAssetAtPath(objectPath, typeof(CharacterJobList)) as CharacterJobList; } }
void CreateNewJobList() { // 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; CharacterJobList = CreateCharacterJobList.Create(); if (CharacterJobList) { CharacterJobList.JobList = new List <CharacterJob>(); string relPath = AssetDatabase.GetAssetPath(CharacterJobList); EditorPrefs.SetString("ObjectPath", relPath); } }
void OpenJobList() { string absPath = EditorUtility.OpenFilePanel("Select Character Job List", "", ""); if (absPath.StartsWith(Application.dataPath)) { string relPath = absPath.Substring(Application.dataPath.Length - "Assets".Length); CharacterJobList = AssetDatabase.LoadAssetAtPath(relPath, typeof(CharacterJobList)) as CharacterJobList; if (CharacterJobList.JobList == null) { CharacterJobList.JobList = new List <CharacterJob>(); } if (CharacterJobList) { EditorPrefs.SetString("ObjectPath", relPath); } } }