Skip to content

Instantly share code, notes, and snippets.

@ZeredaGames
Last active February 27, 2019 13:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ZeredaGames/ca67fcfc48be9479602f83dbe2c169a2 to your computer and use it in GitHub Desktop.
Save ZeredaGames/ca67fcfc48be9479602f83dbe2c169a2 to your computer and use it in GitHub Desktop.
Option B
#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