Beispiel #1
0
 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);
        }
Beispiel #3
0
 void CreateNewLevelList()
 {
     _viewIndex = 1;
     _levelList = CreateLevelList.Create();
     if (_levelList)
     {
         _levelList.levels = new List <LevelData>();
         string relPath = AssetDatabase.GetAssetPath(_levelList);
         EditorPrefs.SetString("ObjectPath", relPath);
     }
 }
Beispiel #4
0
        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);
                }
            }
        }