Files
BITFALL/Assets/BITKit/Unity/Scripts/Utility/ScriptableObjectHelper.cs
CortexCore 45913c6b3e 1
2023-08-23 01:59:40 +08:00

26 lines
654 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace BITKit
{
public static class ScriptableObjectHelper
{
public static T Get<T>() where T : ScriptableObject
{
string name = typeof(T).Name;
T so = Resources.Load<T>(name);
#if UNITY_EDITOR
if (so is null)
{
so = ScriptableObject.CreateInstance<T>();
AssetDatabase.CreateAsset(so, $"Assets/Resources/{name}.asset");
AssetDatabase.SaveAssets();
}
#endif
return so;
}
}
}