From 6de31e5ee91f6374635155b30e2f0256374fb395 Mon Sep 17 00:00:00 2001 From: hevinci Date: Sun, 25 Jun 2023 12:03:19 +0800 Subject: [PATCH] update runtime code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增LoadAllAssetsAsync方法 --- .../Runtime/AssetSystem/AssetSystem.cs | 36 +++++- .../Handles/AllAssetsOperationHandle.cs | 80 +++++++++++++ .../Handles/AllAssetsOperationHandle.cs.meta | 11 ++ .../Provider/BundledAllAssetsProvider.cs | 112 ++++++++++++++++++ .../Provider/BundledAllAssetsProvider.cs.meta | 11 ++ .../Provider/DatabaseAllAssetsProvider.cs | 105 ++++++++++++++++ .../DatabaseAllAssetsProvider.cs.meta | 11 ++ .../AssetSystem/Provider/ProviderBase.cs | 2 + .../Runtime/PackageSystem/BundleInfo.cs | 15 +-- .../Runtime/PackageSystem/PackageManifest.cs | 19 +++ .../PlayMode/EditorSimulateModeImpl.cs | 7 +- .../Runtime/PackageSystem/ResourcePackage.cs | 89 ++++++++++++++ Assets/YooAsset/Runtime/YooAssetsExtension.cs | 67 +++++++++++ 13 files changed, 545 insertions(+), 20 deletions(-) create mode 100644 Assets/YooAsset/Runtime/AssetSystem/Handles/AllAssetsOperationHandle.cs create mode 100644 Assets/YooAsset/Runtime/AssetSystem/Handles/AllAssetsOperationHandle.cs.meta create mode 100644 Assets/YooAsset/Runtime/AssetSystem/Provider/BundledAllAssetsProvider.cs create mode 100644 Assets/YooAsset/Runtime/AssetSystem/Provider/BundledAllAssetsProvider.cs.meta create mode 100644 Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseAllAssetsProvider.cs create mode 100644 Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseAllAssetsProvider.cs.meta diff --git a/Assets/YooAsset/Runtime/AssetSystem/AssetSystem.cs b/Assets/YooAsset/Runtime/AssetSystem/AssetSystem.cs index b2a94a0..e65c437 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/AssetSystem.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/AssetSystem.cs @@ -238,6 +238,34 @@ namespace YooAsset return provider.CreateHandle(); } + /// + /// 加载所有资源对象 + /// + public AllAssetsOperationHandle LoadAllAssetsAsync(AssetInfo assetInfo) + { + if (assetInfo.IsInvalid) + { + YooLogger.Error($"Failed to load all assets ! {assetInfo.Error}"); + CompletedProvider completedProvider = new CompletedProvider(assetInfo); + completedProvider.SetCompleted(assetInfo.Error); + return completedProvider.CreateHandle(); + } + + string providerGUID = assetInfo.GUID; + ProviderBase provider = TryGetProvider(providerGUID); + if (provider == null) + { + if (_simulationOnEditor) + provider = new DatabaseAllAssetsProvider(this, providerGUID, assetInfo); + else + provider = new BundledAllAssetsProvider(this, providerGUID, assetInfo); + provider.InitSpawnDebugInfo(); + _providerList.Add(provider); + _providerDic.Add(providerGUID, provider); + } + return provider.CreateHandle(); + } + /// /// 加载原生文件 /// @@ -355,10 +383,10 @@ namespace YooAsset else { #if UNITY_WEBGL - if (bundleInfo.Bundle.IsRawFile) - loader = new RawBundleWebLoader(this, bundleInfo); - else - loader = new AssetBundleWebLoader(this, bundleInfo); + if (bundleInfo.Bundle.IsRawFile) + loader = new RawBundleWebLoader(this, bundleInfo); + else + loader = new AssetBundleWebLoader(this, bundleInfo); #else if (bundleInfo.Bundle.IsRawFile) loader = new RawBundleFileLoader(this, bundleInfo); diff --git a/Assets/YooAsset/Runtime/AssetSystem/Handles/AllAssetsOperationHandle.cs b/Assets/YooAsset/Runtime/AssetSystem/Handles/AllAssetsOperationHandle.cs new file mode 100644 index 0000000..532bc27 --- /dev/null +++ b/Assets/YooAsset/Runtime/AssetSystem/Handles/AllAssetsOperationHandle.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; + +namespace YooAsset +{ + public sealed class AllAssetsOperationHandle : OperationHandleBase, IDisposable + { + private System.Action _callback; + + internal AllAssetsOperationHandle(ProviderBase provider) : base(provider) + { + } + internal override void InvokeCallback() + { + _callback?.Invoke(this); + } + + /// + /// 完成委托 + /// + public event System.Action Completed + { + add + { + if (IsValidWithWarning == false) + throw new System.Exception($"{nameof(AllAssetsOperationHandle)} is invalid"); + if (Provider.IsDone) + value.Invoke(this); + else + _callback += value; + } + remove + { + if (IsValidWithWarning == false) + throw new System.Exception($"{nameof(AllAssetsOperationHandle)} is invalid"); + _callback -= value; + } + } + + /// + /// 等待异步执行完毕 + /// + public void WaitForAsyncComplete() + { + if (IsValidWithWarning == false) + return; + Provider.WaitForAsyncComplete(); + } + + /// + /// 释放资源句柄 + /// + public void Release() + { + this.ReleaseInternal(); + } + + /// + /// 释放资源句柄 + /// + public void Dispose() + { + this.ReleaseInternal(); + } + + + /// + /// 子资源对象集合 + /// + public UnityEngine.Object[] AllAssetObjects + { + get + { + if (IsValidWithWarning == false) + return null; + return Provider.AllAssetObjects; + } + } + } +} \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/AssetSystem/Handles/AllAssetsOperationHandle.cs.meta b/Assets/YooAsset/Runtime/AssetSystem/Handles/AllAssetsOperationHandle.cs.meta new file mode 100644 index 0000000..65ac0d5 --- /dev/null +++ b/Assets/YooAsset/Runtime/AssetSystem/Handles/AllAssetsOperationHandle.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6de8dc2be5f52704abe6db03818edff2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledAllAssetsProvider.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledAllAssetsProvider.cs new file mode 100644 index 0000000..98b1632 --- /dev/null +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledAllAssetsProvider.cs @@ -0,0 +1,112 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace YooAsset +{ + internal sealed class BundledAllAssetsProvider : ProviderBase + { + private AssetBundleRequest _cacheRequest; + + public BundledAllAssetsProvider(AssetSystemImpl impl, string providerGUID, AssetInfo assetInfo) : base(impl, providerGUID, assetInfo) + { + } + public override void Update() + { + DebugBeginRecording(); + + if (IsDone) + return; + + if (Status == EStatus.None) + { + Status = EStatus.CheckBundle; + } + + // 1. 检测资源包 + if (Status == EStatus.CheckBundle) + { + if (IsWaitForAsyncComplete) + { + DependBundleGroup.WaitForAsyncComplete(); + OwnerBundle.WaitForAsyncComplete(); + } + + if (DependBundleGroup.IsDone() == false) + return; + if (OwnerBundle.IsDone() == false) + return; + + if (DependBundleGroup.IsSucceed() == false) + { + Status = EStatus.Failed; + LastError = DependBundleGroup.GetLastError(); + InvokeCompletion(); + return; + } + + if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed) + { + Status = EStatus.Failed; + LastError = OwnerBundle.LastError; + InvokeCompletion(); + return; + } + + Status = EStatus.Loading; + } + + // 2. 加载资源对象 + if (Status == EStatus.Loading) + { + if (IsWaitForAsyncComplete) + { + if (MainAssetInfo.AssetType == null) + AllAssetObjects = OwnerBundle.CacheBundle.LoadAllAssets(); + else + AllAssetObjects = OwnerBundle.CacheBundle.LoadAllAssets(MainAssetInfo.AssetType); + } + else + { + if (MainAssetInfo.AssetType == null) + _cacheRequest = OwnerBundle.CacheBundle.LoadAllAssetsAsync(); + else + _cacheRequest = OwnerBundle.CacheBundle.LoadAllAssetsAsync(MainAssetInfo.AssetType); + } + Status = EStatus.Checking; + } + + // 3. 检测加载结果 + if (Status == EStatus.Checking) + { + if (_cacheRequest != null) + { + if (IsWaitForAsyncComplete) + { + // 强制挂起主线程(注意:该操作会很耗时) + YooLogger.Warning("Suspend the main thread to load unity asset."); + AllAssetObjects = _cacheRequest.allAssets; + } + else + { + Progress = _cacheRequest.progress; + if (_cacheRequest.isDone == false) + return; + AllAssetObjects = _cacheRequest.allAssets; + } + } + + Status = AllAssetObjects == null ? EStatus.Failed : EStatus.Succeed; + if (Status == EStatus.Failed) + { + if (MainAssetInfo.AssetType == null) + LastError = $"Failed to load all assets : {MainAssetInfo.AssetPath} AssetType : null AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}"; + else + LastError = $"Failed to load all assets : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType} AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}"; + YooLogger.Error(LastError); + } + InvokeCompletion(); + } + } + } +} \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledAllAssetsProvider.cs.meta b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledAllAssetsProvider.cs.meta new file mode 100644 index 0000000..ae86b33 --- /dev/null +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledAllAssetsProvider.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9b0e966838827284a9266a9f2237a460 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseAllAssetsProvider.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseAllAssetsProvider.cs new file mode 100644 index 0000000..44e98d6 --- /dev/null +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseAllAssetsProvider.cs @@ -0,0 +1,105 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace YooAsset +{ + internal sealed class DatabaseAllAssetsProvider : ProviderBase + { + public DatabaseAllAssetsProvider(AssetSystemImpl impl, string providerGUID, AssetInfo assetInfo) : base(impl, providerGUID, assetInfo) + { + } + public override void Update() + { +#if UNITY_EDITOR + if (IsDone) + return; + + if (Status == EStatus.None) + { + // 检测资源文件是否存在 + string guid = UnityEditor.AssetDatabase.AssetPathToGUID(MainAssetInfo.AssetPath); + if (string.IsNullOrEmpty(guid)) + { + Status = EStatus.Failed; + LastError = $"Not found asset : {MainAssetInfo.AssetPath}"; + YooLogger.Error(LastError); + InvokeCompletion(); + return; + } + + Status = EStatus.CheckBundle; + + // 注意:模拟异步加载效果提前返回 + if (IsWaitForAsyncComplete == false) + return; + } + + // 1. 检测资源包 + if (Status == EStatus.CheckBundle) + { + if (IsWaitForAsyncComplete) + { + OwnerBundle.WaitForAsyncComplete(); + } + + if (OwnerBundle.IsDone() == false) + return; + + if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed) + { + Status = EStatus.Failed; + LastError = OwnerBundle.LastError; + InvokeCompletion(); + return; + } + + Status = EStatus.Loading; + } + + // 2. 加载资源对象 + if (Status == EStatus.Loading) + { + if (MainAssetInfo.AssetType == null) + { + List result = new List(); + foreach (var assetPath in OwnerBundle.MainBundleInfo.IncludeAssets) + { + UnityEngine.Object mainAsset = UnityEditor.AssetDatabase.LoadMainAssetAtPath(assetPath); + if (mainAsset != null) + result.Add(mainAsset); + } + AllAssetObjects = result.ToArray(); + } + else + { + List result = new List(); + foreach (var assetPath in OwnerBundle.MainBundleInfo.IncludeAssets) + { + UnityEngine.Object mainAsset = UnityEditor.AssetDatabase.LoadAssetAtPath(assetPath, MainAssetInfo.AssetType); + if (mainAsset != null) + result.Add(mainAsset); + } + AllAssetObjects = result.ToArray(); + } + Status = EStatus.Checking; + } + + // 3. 检测加载结果 + if (Status == EStatus.Checking) + { + Status = AllAssetObjects == null ? EStatus.Failed : EStatus.Succeed; + if (Status == EStatus.Failed) + { + if (MainAssetInfo.AssetType == null) + LastError = $"Failed to load all assets : {MainAssetInfo.AssetPath} AssetType : null"; + else + LastError = $"Failed to load all assets : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType}"; + YooLogger.Error(LastError); + } + InvokeCompletion(); + } +#endif + } + } +} \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseAllAssetsProvider.cs.meta b/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseAllAssetsProvider.cs.meta new file mode 100644 index 0000000..93e2b0e --- /dev/null +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseAllAssetsProvider.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c72eb6001f903de46bc72dea0d8b39c5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/ProviderBase.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/ProviderBase.cs index aa01530..ee449af 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Provider/ProviderBase.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/ProviderBase.cs @@ -177,6 +177,8 @@ namespace YooAsset handle = new SceneOperationHandle(this); else if (typeof(T) == typeof(SubAssetsOperationHandle)) handle = new SubAssetsOperationHandle(this); + else if (typeof(T) == typeof(AllAssetsOperationHandle)) + handle = new AllAssetsOperationHandle(this); else if (typeof(T) == typeof(RawFileOperationHandle)) handle = new RawFileOperationHandle(this); else diff --git a/Assets/YooAsset/Runtime/PackageSystem/BundleInfo.cs b/Assets/YooAsset/Runtime/PackageSystem/BundleInfo.cs index 18e9007..793deb2 100644 --- a/Assets/YooAsset/Runtime/PackageSystem/BundleInfo.cs +++ b/Assets/YooAsset/Runtime/PackageSystem/BundleInfo.cs @@ -26,9 +26,9 @@ namespace YooAsset public string RemoteFallbackURL { private set; get; } /// - /// 编辑器资源路径 + /// 注意:该字段只用于帮助编辑器下的模拟模式。 /// - public string EditorAssetPath { private set; get; } + public string[] IncludeAssets; private BundleInfo() @@ -40,15 +40,6 @@ namespace YooAsset LoadMode = loadMode; RemoteMainURL = mainURL; RemoteFallbackURL = fallbackURL; - EditorAssetPath = string.Empty; - } - public BundleInfo(PackageBundle bundle, ELoadMode loadMode, string editorAssetPath) - { - Bundle = bundle; - LoadMode = loadMode; - RemoteMainURL = string.Empty; - RemoteFallbackURL = string.Empty; - EditorAssetPath = editorAssetPath; } public BundleInfo(PackageBundle bundle, ELoadMode loadMode) { @@ -56,10 +47,8 @@ namespace YooAsset LoadMode = loadMode; RemoteMainURL = string.Empty; RemoteFallbackURL = string.Empty; - EditorAssetPath = string.Empty; } - /// /// 是否为JAR包内文件 /// diff --git a/Assets/YooAsset/Runtime/PackageSystem/PackageManifest.cs b/Assets/YooAsset/Runtime/PackageSystem/PackageManifest.cs index a2d4948..8b55afd 100644 --- a/Assets/YooAsset/Runtime/PackageSystem/PackageManifest.cs +++ b/Assets/YooAsset/Runtime/PackageSystem/PackageManifest.cs @@ -308,6 +308,25 @@ namespace YooAsset } } + /// + /// 获取资源包内的主资源列表 + /// + public string[] GetBundleIncludeAssets(string assetPath) + { + List assetList = new List(); + if (TryGetPackageAsset(assetPath, out PackageAsset result)) + { + foreach (var packageAsset in AssetList) + { + if (packageAsset.BundleID == result.BundleID) + { + assetList.Add(packageAsset.AssetPath); + } + } + } + return assetList.ToArray(); + } + #region 调试方法 [Conditional("DEBUG")] private void DebugCheckLocation(string location) diff --git a/Assets/YooAsset/Runtime/PackageSystem/PlayMode/EditorSimulateModeImpl.cs b/Assets/YooAsset/Runtime/PackageSystem/PlayMode/EditorSimulateModeImpl.cs index 57d7da8..6d5ad26 100644 --- a/Assets/YooAsset/Runtime/PackageSystem/PlayMode/EditorSimulateModeImpl.cs +++ b/Assets/YooAsset/Runtime/PackageSystem/PlayMode/EditorSimulateModeImpl.cs @@ -33,7 +33,7 @@ namespace YooAsset return _activeManifest; } } - public void FlushManifestVersionFile() + public void FlushManifestVersionFile() { } @@ -55,7 +55,7 @@ namespace YooAsset OperationSystem.StartOperation(operation); return operation; } - + ResourceDownloaderOperation IPlayModeServices.CreateResourceDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout) { return ResourceDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout); @@ -85,7 +85,8 @@ namespace YooAsset if (packageBundle == null) throw new Exception("Should never get here !"); - BundleInfo bundleInfo = new BundleInfo(packageBundle, BundleInfo.ELoadMode.LoadFromEditor, assetInfo.AssetPath); + BundleInfo bundleInfo = new BundleInfo(packageBundle, BundleInfo.ELoadMode.LoadFromEditor); + bundleInfo.IncludeAssets = _activeManifest.GetBundleIncludeAssets(assetInfo.AssetPath); return bundleInfo; } BundleInfo IBundleServices.GetBundleInfo(AssetInfo assetInfo) diff --git a/Assets/YooAsset/Runtime/PackageSystem/ResourcePackage.cs b/Assets/YooAsset/Runtime/PackageSystem/ResourcePackage.cs index 7671cdb..30f2d0f 100644 --- a/Assets/YooAsset/Runtime/PackageSystem/ResourcePackage.cs +++ b/Assets/YooAsset/Runtime/PackageSystem/ResourcePackage.cs @@ -650,6 +650,95 @@ namespace YooAsset } #endregion + #region 资源加载 + /// + /// 同步加载资源包内所有资源对象 + /// + /// 资源信息 + public AllAssetsOperationHandle LoadAllAssetsSync(AssetInfo assetInfo) + { + DebugCheckInitialize(); + return LoadAllAssetsInternal(assetInfo, true); + } + + /// + /// 同步加载资源包内所有资源对象 + /// + /// 资源类型 + /// 资源的定位地址 + public AllAssetsOperationHandle LoadAllAssetsSync(string location) where TObject : UnityEngine.Object + { + DebugCheckInitialize(); + AssetInfo assetInfo = ConvertLocationToAssetInfo(location, typeof(TObject)); + return LoadAllAssetsInternal(assetInfo, true); + } + + /// + /// 同步加载资源包内所有资源对象 + /// + /// 资源的定位地址 + /// 子对象类型 + public AllAssetsOperationHandle LoadAllAssetsSync(string location, System.Type type) + { + DebugCheckInitialize(); + AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type); + return LoadAllAssetsInternal(assetInfo, true); + } + + + /// + /// 异步加载资源包内所有资源对象 + /// + /// 资源信息 + public AllAssetsOperationHandle LoadAllAssetsAsync(AssetInfo assetInfo) + { + DebugCheckInitialize(); + return LoadAllAssetsInternal(assetInfo, false); + } + + /// + /// 异步加载资源包内所有资源对象 + /// + /// 资源类型 + /// 资源的定位地址 + public AllAssetsOperationHandle LoadAllAssetsAsync(string location) where TObject : UnityEngine.Object + { + DebugCheckInitialize(); + AssetInfo assetInfo = ConvertLocationToAssetInfo(location, typeof(TObject)); + return LoadAllAssetsInternal(assetInfo, false); + } + + /// + /// 异步加载资源包内所有资源对象 + /// + /// 资源的定位地址 + /// 子对象类型 + public AllAssetsOperationHandle LoadAllAssetsAsync(string location, System.Type type) + { + DebugCheckInitialize(); + AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type); + return LoadAllAssetsInternal(assetInfo, false); + } + + + private AllAssetsOperationHandle LoadAllAssetsInternal(AssetInfo assetInfo, bool waitForAsyncComplete) + { +#if UNITY_EDITOR + if (assetInfo.IsInvalid == false) + { + BundleInfo bundleInfo = _bundleServices.GetBundleInfo(assetInfo); + if (bundleInfo.Bundle.IsRawFile) + throw new Exception($"Cannot load raw file using {nameof(LoadAllAssetsAsync)} method !"); + } +#endif + + var handle = _assetSystemImpl.LoadAllAssetsAsync(assetInfo); + if (waitForAsyncComplete) + handle.WaitForAsyncComplete(); + return handle; + } + #endregion + #region 资源下载 /// /// 创建资源下载器,用于下载当前资源版本所有的资源包文件 diff --git a/Assets/YooAsset/Runtime/YooAssetsExtension.cs b/Assets/YooAsset/Runtime/YooAssetsExtension.cs index 5fb9904..3ec457a 100644 --- a/Assets/YooAsset/Runtime/YooAssetsExtension.cs +++ b/Assets/YooAsset/Runtime/YooAssetsExtension.cs @@ -284,6 +284,73 @@ namespace YooAsset } #endregion + #region 资源加载 + /// + /// 同步加载资源包内所有资源对象 + /// + /// 资源信息 + public static AllAssetsOperationHandle LoadAllAssetsSync(AssetInfo assetInfo) + { + DebugCheckDefaultPackageValid(); + return _defaultPackage.LoadAllAssetsSync(assetInfo); + } + + /// + /// 同步加载资源包内所有资源对象 + /// + /// 资源类型 + /// 资源的定位地址 + public static AllAssetsOperationHandle LoadAllAssetsSync(string location) where TObject : UnityEngine.Object + { + DebugCheckDefaultPackageValid(); + return _defaultPackage.LoadAllAssetsSync(location); + } + + /// + /// 同步加载资源包内所有资源对象 + /// + /// 资源的定位地址 + /// 子对象类型 + public static AllAssetsOperationHandle LoadAllAssetsSync(string location, System.Type type) + { + DebugCheckDefaultPackageValid(); + return _defaultPackage.LoadAllAssetsSync(location, type); + } + + + /// + /// 异步加载资源包内所有资源对象 + /// + /// 资源信息 + public static AllAssetsOperationHandle LoadAllAssetsAsync(AssetInfo assetInfo) + { + DebugCheckDefaultPackageValid(); + return _defaultPackage.LoadAllAssetsAsync(assetInfo); + } + + /// + /// 异步加载资源包内所有资源对象 + /// + /// 资源类型 + /// 资源的定位地址 + public static AllAssetsOperationHandle LoadAllAssetsAsync(string location) where TObject : UnityEngine.Object + { + DebugCheckDefaultPackageValid(); + return _defaultPackage.LoadAllAssetsAsync(location); + } + + /// + /// 异步加载资源包内所有资源对象 + /// + /// 资源的定位地址 + /// 子对象类型 + public static AllAssetsOperationHandle LoadAllAssetsAsync(string location, System.Type type) + { + DebugCheckDefaultPackageValid(); + return _defaultPackage.LoadAllAssetsAsync(location, type); + } + #endregion + #region 资源下载 /// /// 创建资源下载器,用于下载当前资源版本所有的资源包文件