This commit is contained in:
CortexCore
2023-06-05 19:57:17 +08:00
parent f05e28ec58
commit 7f2fea821c
6195 changed files with 489001 additions and 636 deletions

View File

@@ -0,0 +1,26 @@
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;
}
}
}