From bc38159beda942e6e80557f01e562c169c113dd0 Mon Sep 17 00:00:00 2001 From: hevinci Date: Fri, 7 Jul 2023 12:16:16 +0800 Subject: [PATCH] update asset system MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 真机上使用错误方法加载原生文件的时候给予正确的错误提示。 --- .../Provider/BundledAllAssetsProvider.cs | 6 +++++ .../Provider/BundledAssetProvider.cs | 7 +----- .../Provider/BundledSubAssetsProvider.cs | 6 +++++ .../AssetSystem/Provider/ProviderBase.cs | 24 +++++++++++++++++++ 4 files changed, 37 insertions(+), 6 deletions(-) diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledAllAssetsProvider.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledAllAssetsProvider.cs index bfbf3e2..d5d2ee9 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledAllAssetsProvider.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledAllAssetsProvider.cs @@ -53,6 +53,12 @@ namespace YooAsset return; } + if (OwnerBundle.CacheBundle == null) + { + ProcessCacheBundleException(); + return; + } + Status = EStatus.Loading; } diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledAssetProvider.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledAssetProvider.cs index af83277..4d83c7b 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledAssetProvider.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledAssetProvider.cs @@ -55,12 +55,7 @@ namespace YooAsset if (OwnerBundle.CacheBundle == null) { - if (OwnerBundle.IsDestroyed) - throw new System.Exception("Should never get here !"); - Status = EStatus.Failed; - LastError = $"The bundle {OwnerBundle.MainBundleInfo.Bundle.BundleName} has been destroyed by unity bugs !"; - YooLogger.Error(LastError); - InvokeCompletion(); + ProcessCacheBundleException(); return; } diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledSubAssetsProvider.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledSubAssetsProvider.cs index f48fb65..58dece6 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledSubAssetsProvider.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledSubAssetsProvider.cs @@ -53,6 +53,12 @@ namespace YooAsset return; } + if (OwnerBundle.CacheBundle == null) + { + ProcessCacheBundleException(); + return; + } + Status = EStatus.Loading; } diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/ProviderBase.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/ProviderBase.cs index 445e00d..5afc00b 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Provider/ProviderBase.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/ProviderBase.cs @@ -220,6 +220,30 @@ namespace YooAsset } } + /// + /// 处理特殊异常 + /// + protected void ProcessCacheBundleException() + { + if (OwnerBundle.IsDestroyed) + throw new System.Exception("Should never get here !"); + + if (OwnerBundle.MainBundleInfo.Bundle.IsRawFile) + { + Status = EStatus.Failed; + LastError = $"Cannot load asset bundle file using {nameof(ResourcePackage.LoadRawFileAsync)} method !"; + YooLogger.Error(LastError); + InvokeCompletion(); + } + else + { + Status = EStatus.Failed; + LastError = $"The bundle {OwnerBundle.MainBundleInfo.Bundle.BundleName} has been destroyed by unity bugs !"; + YooLogger.Error(LastError); + InvokeCompletion(); + } + } + /// /// 异步操作任务 ///