Files
beyond/Assets/Scripts/InvectorDerivatives/bScriptableObjectUtility.cs
2024-11-20 15:21:28 +01:00

23 lines
753 B
C#

#if UNITY_EDITOR
using UnityEngine;
using UnityEditor;
namespace Beyond
{
public static class bScriptableObjectUtility
{
/// <summary>
/// Create new asset from <see cref="ScriptableObject"/> type with unique Name at
/// selected folder in project window. Asset creation can be cancelled by pressing
/// escape key when asset is initially being named.
/// </summary>
/// <typeparam Name="T">Type of scriptable object.</typeparam>
///
public static void CreateAsset<T>() where T : ScriptableObject
{
var asset = ScriptableObject.CreateInstance<T>();
ProjectWindowUtil.CreateAsset(asset, "New " + typeof(T).Name + ".asset");
}
}
}
#endif