From 79efe6237d864a1c0ba8b882b3b7df239460bda0 Mon Sep 17 00:00:00 2001 From: hevinci Date: Mon, 9 May 2022 21:18:15 +0800 Subject: [PATCH] Update asset system --- .../Provider/BundledAssetProvider.cs | 5 ++++- .../Provider/BundledSubAssetsProvider.cs | 5 ++++- .../Provider/DatabaseAssetProvider.cs | 20 +++++++++++++++++-- .../Provider/DatabaseSubAssetsProvider.cs | 5 ++++- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledAssetProvider.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledAssetProvider.cs index fcffcbc..c104aae 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledAssetProvider.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledAssetProvider.cs @@ -106,7 +106,10 @@ namespace YooAsset Status = AssetObject == null ? EStatus.Fail : EStatus.Success; if (Status == EStatus.Fail) { - LastError = $"Failed to load asset : {AssetName} from bundle : {OwnerBundle.BundleFileInfo.BundleName}"; + if(AssetType == null) + LastError = $"Failed to load asset : {AssetName} AssetType : null AssetBundle : {OwnerBundle.BundleFileInfo.BundleName}"; + else + LastError = $"Failed to load asset : {AssetName} AssetType : {AssetType} AssetBundle : {OwnerBundle.BundleFileInfo.BundleName}"; YooLogger.Error(LastError); } InvokeCompletion(); diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledSubAssetsProvider.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledSubAssetsProvider.cs index 321d875..6194e68 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledSubAssetsProvider.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledSubAssetsProvider.cs @@ -106,7 +106,10 @@ namespace YooAsset Status = AllAssetObjects == null ? EStatus.Fail : EStatus.Success; if (Status == EStatus.Fail) { - LastError = $"Failed to load sub assets : {AssetName} from bundle : {OwnerBundle.BundleFileInfo.BundleName}"; + if (AssetType == null) + LastError = $"Failed to load sub assets : {AssetName} AssetType : null AssetBundle : {OwnerBundle.BundleFileInfo.BundleName}"; + else + LastError = $"Failed to load sub assets : {AssetName} AssetType : {AssetType} AssetBundle : {OwnerBundle.BundleFileInfo.BundleName}"; YooLogger.Error(LastError); } InvokeCompletion(); diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseAssetProvider.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseAssetProvider.cs index 6cb6207..ca8c704 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseAssetProvider.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseAssetProvider.cs @@ -60,12 +60,28 @@ namespace YooAsset // 2. 检测加载结果 if (Status == EStatus.Checking) { + if (AssetObject != null) + { + if (UnityEditor.AssetDatabase.IsMainAsset(AssetObject) == false) + { + AssetObject = null; + Status = EStatus.Fail; + LastError = $"The loaded asset object is not main asset : {AssetPath} AssetType : {AssetType}"; + YooLogger.Error(LastError); + InvokeCompletion(); + return; + } + } + Status = AssetObject == null ? EStatus.Fail : EStatus.Success; if (Status == EStatus.Fail) { - LastError = $"Failed to load asset object : {AssetPath}"; + if (AssetType == null) + LastError = $"Failed to load asset object : {AssetPath} AssetType : null"; + else + LastError = $"Failed to load asset object : {AssetPath} AssetType : {AssetType}"; YooLogger.Error(LastError); - } + } InvokeCompletion(); } #endif diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseSubAssetsProvider.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseSubAssetsProvider.cs index ad9b982..ad71171 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseSubAssetsProvider.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseSubAssetsProvider.cs @@ -74,7 +74,10 @@ namespace YooAsset Status = AllAssetObjects == null ? EStatus.Fail : EStatus.Success; if (Status == EStatus.Fail) { - LastError = $"Failed to load sub assets : {nameof(AssetType)} in {AssetPath}"; + if (AssetType == null) + LastError = $"Failed to load sub assets : {AssetPath} AssetType : null"; + else + LastError = $"Failed to load sub assets : {AssetPath} AssetType : {AssetType}"; YooLogger.Error(LastError); } InvokeCompletion();