Last active
February 27, 2019 13:25
-
-
Save ZeredaGames/ca67fcfc48be9479602f83dbe2c169a2 to your computer and use it in GitHub Desktop.
Option B
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#region usings | |
using UnityEngine; | |
#if UNITY_EDITOR | |
using UnityEditor; | |
#endif | |
//using UnityEngine.UI; | |
//using UnityEngine.SceneManagement; | |
//using System; | |
//using System.Collections; | |
using System.Collections.Generic; | |
#endregion | |
#region Script | |
namespace ZeredaGamesEngine.Core.MusicListsExamples.Example3 | |
{ | |
#region Attributes | |
//[RequireComponent (typeof())] | |
[System.Serializable] | |
#endregion | |
[CreateAssetMenu(menuName = "My custom button name", fileName = "NewInstanceOf_MyScriptableObject.asset")] | |
public class MusicAssetList : ScriptableObject | |
{ | |
public List<AudioClip> PlayList = new List<AudioClip>(); | |
static MusicAssetList asset =null; | |
public static bool DebugMode; | |
public static string Path = "Assets/Resources"; | |
public static string FolderName = "Music"; | |
public static string AssetName = "NewAsset"; | |
#if UNITY_EDITOR | |
[MenuItem("ZeredaGames/Game Making Editor Tools/Create Playlist/General Music", false, 1)] | |
public static MusicAssetList CreateNewAsset() | |
{ | |
//Of the ScriptableObject "asset". | |
asset = ScriptableObject.CreateInstance<MusicAssetList>(); | |
//in the Folder Assets/Resources/GeneralGameAssets/AssetName.asset. | |
AssetDatabase.CreateAsset(asset, Path + "/" + FolderName + "/" + AssetName + ".asset"); | |
if (DebugMode) | |
Debug.Log("New Asset Created in: " + FolderName + " @ setPath(" + Path + FolderName + "/" + AssetName + ".asset) \t AssetName"); | |
//and than saves it there . | |
AssetDatabase.SaveAssets(); | |
//Set Unity's selection. | |
Selection.activeObject = asset; | |
//Focus on that selection. | |
EditorUtility.FocusProjectWindow(); | |
//Return the asset. | |
return asset; | |
} | |
#endif | |
} | |
} | |
#endregion |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment