74 lines
2.6 KiB
C#
74 lines
2.6 KiB
C#
//using System;
|
|
//using Cysharp.Threading.Tasks;
|
|
//using UnityEngine;
|
|
//using System.Threading;
|
|
|
|
///*
|
|
// * 此代码由 AI 与悟空框架团队合作完成
|
|
// * 资源加载助手,提供统一的资源加载接口
|
|
// * 作为悟空框架的扩展解决方案,用于桥接具体的资源加载实现
|
|
// */
|
|
//public static class ResHelper
|
|
//{
|
|
// public static Func<UniTask> Initialize { get; set; }
|
|
|
|
// public static Func<string, Type, UnityEngine.Object> LoadAssetImpl { get; set; }
|
|
// public static Func<string, Type, UniTask<UnityEngine.Object>> LoadAssetAsyncImpl { get; set; }
|
|
// public static Func<string, Type, Action<UnityEngine.Object>, Action<string>, int> LoadAssetAsyncImplH { get; set; }
|
|
|
|
// public static Action<UnityEngine.Object> UnloadAssetImpl { get; set; }
|
|
// public static Action<int> UnloadAssetImplH { get; set; }
|
|
|
|
// //public static T LoadAsset<T>(string path) where T : UnityEngine.Object
|
|
// //{
|
|
// // if (LoadAssetImpl == null)
|
|
// // {
|
|
// // Debug.LogError("LoadAssetImpl is not initialized");
|
|
// // return null;
|
|
// // }
|
|
// // return LoadAssetImpl(path, typeof(T)) as T;
|
|
// //}
|
|
|
|
// public static async UniTask<T> LoadAssetAsync<T>(string path, CancellationToken cancellationToken = default) where T : UnityEngine.Object
|
|
// {
|
|
// if (LoadAssetAsyncImpl == null)
|
|
// {
|
|
// Debug.LogError("LoadAssetAsyncImpl is not initialized");
|
|
// return null;
|
|
// }
|
|
|
|
// var obj = await LoadAssetAsyncImpl(path, typeof(T)).AttachExternalCancellation(cancellationToken);
|
|
// return obj as T;
|
|
// }
|
|
|
|
// public static int LoadAssetAsync<T>(string path, Action<T> callback, Action<string> errorCallback = null) where T : UnityEngine.Object
|
|
// {
|
|
// if (LoadAssetAsyncImplH == null)
|
|
// {
|
|
// errorCallback?.Invoke("LoadAssetAsyncImplH is not initialized");
|
|
// return -1;
|
|
// }
|
|
|
|
// return LoadAssetAsyncImplH(path, typeof(T), callback as Action<UnityEngine.Object>, errorCallback);
|
|
// }
|
|
|
|
// public static void UnloadAsset(UnityEngine.Object obj)
|
|
// {
|
|
// if (UnloadAssetImpl == null)
|
|
// {
|
|
// Debug.LogError("UnloadAssetImpl is not initialized");
|
|
// return;
|
|
// }
|
|
// UnloadAssetImpl(obj);
|
|
// }
|
|
|
|
// public static void UnloadAssetHandle(int handle)
|
|
// {
|
|
// if (UnloadAssetImplH == null)
|
|
// {
|
|
// Debug.LogError("UnloadAssetImplH is not initialized");
|
|
// return;
|
|
// }
|
|
// UnloadAssetImplH(handle);
|
|
// }
|
|
//} |