40 lines
1.1 KiB
C#
40 lines
1.1 KiB
C#
|
|
using System.Threading.Tasks;
|
||
|
|
using UnityEngine;
|
||
|
|
using YooAsset;
|
||
|
|
|
||
|
|
namespace Stary.Evo.TableTextConversion
|
||
|
|
{
|
||
|
|
public static class ReadDumpInformation
|
||
|
|
{
|
||
|
|
public static async Task<T> Read<T>() where T : ScriptableObject, ITableData
|
||
|
|
{
|
||
|
|
var conf = YooAssets.LoadAssetAsync($"Config_{typeof(T).Name}");
|
||
|
|
await conf.Task;
|
||
|
|
if (conf.Status == EOperationStatus.Succeed)
|
||
|
|
{
|
||
|
|
return conf.AssetObject as T;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
Debug.LogError("UnityEvo:" + "配置文件:" + typeof(T).Name + "加载失败!!!");
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
#if UNITY_EDITOR
|
||
|
|
public static T ReadInEditor<T>() where T : ScriptableObject, ITableData
|
||
|
|
{
|
||
|
|
// 同步加载并直接返回结果
|
||
|
|
var conf = Resources.Load<T>(typeof(T).Name);
|
||
|
|
|
||
|
|
if (conf != null)
|
||
|
|
{
|
||
|
|
return conf;
|
||
|
|
}
|
||
|
|
|
||
|
|
Debug.LogError($"UnityEvo:配置文件同步加载失败:{typeof(T).Name}");
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
}
|
||
|
|
}
|