/// <summary> /// 获取资源 /// </summary> public T GetAsset <T>(string abPath, string assetName) where T : UnityEngine.Object { T asset = null; AssetBundleTask task = GetTask(abPath, false); task?.Load((ab) => { asset = ab?.LoadAsset <T>(assetName); }); return(asset); }
/// <summary> /// 加载AB包 /// </summary> public AssetBundle LoadAssetBundle(string abPath) { AssetBundle assetbundle = null; AssetBundleTask task = GetTask(abPath, false); task?.Load((ab) => { assetbundle = ab; }); return(assetbundle); }
/// <summary> /// 异步获取资源 /// </summary> public void GetAssetAsync <T>(string abPath, string assetName, Action <T> callback, Action <float> progressCallback = null) where T : UnityEngine.Object { AssetBundleTask task = GetTask(abPath, true); task?.Load((ab) => { Task.CreateTask(GetAssetAsync(ab, assetName, (asset) => { callback?.Invoke(asset as T); }, (progress) => { progressCallback?.Invoke(progress * 0.5f + 0.5f); })); }, (progress) => { progressCallback?.Invoke(progress * 0.5f); }); }
/// <summary> /// 异步加载AB包 /// </summary> public void LoadAssetBundleAsync(string abPath, Action <AssetBundle> callback, Action <float> progressCallback) { AssetBundleTask task = GetTask(abPath, true); task?.Load(callback, progressCallback); }