2025-04-01 18:26:48 +08:00
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using UnityEngine;
|
2025-07-02 18:36:48 +08:00
|
|
|
#if HotUpdate
|
2025-04-01 18:26:48 +08:00
|
|
|
using YooAsset;
|
2025-07-02 18:36:48 +08:00
|
|
|
#endif
|
2025-04-01 18:26:48 +08:00
|
|
|
namespace Stary.Evo.TableTextConversion
|
|
|
|
|
{
|
|
|
|
|
public static class ReadDumpInformation
|
|
|
|
|
{
|
|
|
|
|
public static async Task<T> Read<T>() where T : ScriptableObject, ITableData
|
|
|
|
|
{
|
2025-07-02 18:36:48 +08:00
|
|
|
#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
|
2025-04-01 18:26:48 +08:00
|
|
|
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;
|
|
|
|
|
}
|
2025-07-02 18:36:48 +08:00
|
|
|
#endif
|
2025-08-20 18:31:38 +08:00
|
|
|
return default(T); // 或抛出异常
|
2025-04-01 18:26:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
|
public static T ReadInEditor<T>() where T : ScriptableObject, ITableData
|
|
|
|
|
{
|
|
|
|
|
// 同步加载并直接返回结果
|
|
|
|
|
var conf = Resources.Load<T>(typeof(T).Name);
|
2025-07-02 18:36:48 +08:00
|
|
|
|
2025-04-01 18:26:48 +08:00
|
|
|
if (conf != null)
|
|
|
|
|
{
|
|
|
|
|
return conf;
|
|
|
|
|
}
|
2025-07-02 18:36:48 +08:00
|
|
|
|
2025-04-01 18:26:48 +08:00
|
|
|
Debug.LogError($"UnityEvo:配置文件同步加载失败:{typeof(T).Name}");
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|