Files
2025-08-20 18:31:38 +08:00

55 lines
1.5 KiB
C#

using System.Threading.Tasks;
using UnityEngine;
#if HotUpdate
using YooAsset;
#endif
namespace Stary.Evo.TableTextConversion
{
public static class ReadDumpInformation
{
public static async Task<T> Read<T>() where T : ScriptableObject, ITableData
{
#if NotUpdate
var conf = Resources.Load<T>(typeof(T).Name);
if (conf != null)
{
return conf;
}
else
{
Debug.LogError("UnityEvo:" + "配置文件:" + typeof(T).Name + "加载失败!!!");
return null;
}
#elif HotUpdate
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;
}
#endif
return default(T); // 或抛出异常
}
#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
}
}