From adf1776b1ea037329b07ea7c9ef12e614ad9f521 Mon Sep 17 00:00:00 2001 From: hevinci Date: Sat, 26 Nov 2022 15:31:35 +0800 Subject: [PATCH] Update runtime code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 优化调试信息的加载状态显示为文本。 --- Assets/YooAsset/Runtime/AssetSystem/AssetSystem.cs | 2 +- .../Runtime/AssetSystem/Handles/OperationHandleBase.cs | 4 ++-- .../AssetSystem/Loader/DependAssetBundleGrouper.cs | 2 +- .../Runtime/AssetSystem/Loader/RawBundleFileLoader.cs | 3 --- .../AssetSystem/Provider/BundledAssetProvider.cs | 10 +++++----- .../Runtime/AssetSystem/Provider/BundledProvider.cs | 2 +- .../AssetSystem/Provider/BundledRawFileProvider.cs | 4 ++-- .../AssetSystem/Provider/BundledSceneProvider.cs | 10 +++++----- .../AssetSystem/Provider/BundledSubAssetsProvider.cs | 8 ++++---- .../Runtime/AssetSystem/Provider/CompletedProvider.cs | 2 +- .../AssetSystem/Provider/DatabaseAssetProvider.cs | 6 +++--- .../AssetSystem/Provider/DatabaseRawFileProvider.cs | 4 ++-- .../AssetSystem/Provider/DatabaseSceneProvider.cs | 6 +++--- .../AssetSystem/Provider/DatabaseSubAssetsProvider.cs | 6 +++--- .../Runtime/AssetSystem/Provider/ProviderBase.cs | 6 +++--- .../Runtime/DiagnosticSystem/DebugBundleInfo.cs | 2 +- .../Runtime/DiagnosticSystem/DebugProviderInfo.cs | 2 +- 17 files changed, 38 insertions(+), 41 deletions(-) diff --git a/Assets/YooAsset/Runtime/AssetSystem/AssetSystem.cs b/Assets/YooAsset/Runtime/AssetSystem/AssetSystem.cs index e6b3a39..e9badb7 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/AssetSystem.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/AssetSystem.cs @@ -399,7 +399,7 @@ namespace YooAsset providerInfo.SpawnTime = provider.SpawnTime; providerInfo.LoadingTime = provider.LoadingTime; providerInfo.RefCount = provider.RefCount; - providerInfo.Status = (int)provider.Status; + providerInfo.Status = provider.Status.ToString(); providerInfo.DependBundleInfos = new List(); result.Add(providerInfo); diff --git a/Assets/YooAsset/Runtime/AssetSystem/Handles/OperationHandleBase.cs b/Assets/YooAsset/Runtime/AssetSystem/Handles/OperationHandleBase.cs index d6185e7..18f241f 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Handles/OperationHandleBase.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Handles/OperationHandleBase.cs @@ -32,9 +32,9 @@ namespace YooAsset { if (IsValidWithWarning == false) return EOperationStatus.None; - if (Provider.Status == ProviderBase.EStatus.Fail) + if (Provider.Status == ProviderBase.EStatus.Failed) return EOperationStatus.Failed; - else if (Provider.Status == ProviderBase.EStatus.Success) + else if (Provider.Status == ProviderBase.EStatus.Succeed) return EOperationStatus.Succeed; else return EOperationStatus.None; diff --git a/Assets/YooAsset/Runtime/AssetSystem/Loader/DependAssetBundleGrouper.cs b/Assets/YooAsset/Runtime/AssetSystem/Loader/DependAssetBundleGrouper.cs index 3ad4b71..1de25a3 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Loader/DependAssetBundleGrouper.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Loader/DependAssetBundleGrouper.cs @@ -104,7 +104,7 @@ namespace YooAsset var bundleInfo = new DebugBundleInfo(); bundleInfo.BundleName = loader.MainBundleInfo.Bundle.BundleName; bundleInfo.RefCount = loader.RefCount; - bundleInfo.Status = (int)loader.Status; + bundleInfo.Status = loader.Status.ToString(); output.Add(bundleInfo); } } diff --git a/Assets/YooAsset/Runtime/AssetSystem/Loader/RawBundleFileLoader.cs b/Assets/YooAsset/Runtime/AssetSystem/Loader/RawBundleFileLoader.cs index 5f2da63..90be997 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Loader/RawBundleFileLoader.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Loader/RawBundleFileLoader.cs @@ -16,7 +16,6 @@ namespace YooAsset } private ESteps _steps = ESteps.None; - private bool _isWaitForAsyncComplete = false; private bool _isShowWaitForAsyncError = false; private DownloaderBase _unpacker; private DownloaderBase _downloader; @@ -136,8 +135,6 @@ namespace YooAsset /// public override void WaitForAsyncComplete() { - _isWaitForAsyncComplete = true; - int frame = 1000; while (true) { diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledAssetProvider.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledAssetProvider.cs index dbbf33e..aa31c9e 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledAssetProvider.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledAssetProvider.cs @@ -48,7 +48,7 @@ namespace YooAsset if (DependBundleGroup.IsSucceed() == false) { - Status = EStatus.Fail; + Status = EStatus.Failed; LastError = DependBundleGroup.GetLastError(); InvokeCompletion(); return; @@ -56,7 +56,7 @@ namespace YooAsset if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed) { - Status = EStatus.Fail; + Status = EStatus.Failed; LastError = OwnerBundle.LastError; InvokeCompletion(); return; @@ -66,7 +66,7 @@ namespace YooAsset { if (OwnerBundle.IsDestroyed) throw new System.Exception("Should never get here !"); - Status = EStatus.Fail; + Status = EStatus.Failed; LastError = $"The bundle {OwnerBundle.MainBundleInfo.Bundle.BundleName} has been destroyed by unity bugs !"; YooLogger.Error(LastError); InvokeCompletion(); @@ -115,8 +115,8 @@ namespace YooAsset } } - Status = AssetObject == null ? EStatus.Fail : EStatus.Success; - if (Status == EStatus.Fail) + Status = AssetObject == null ? EStatus.Failed : EStatus.Succeed; + if (Status == EStatus.Failed) { if (MainAssetInfo.AssetType == null) LastError = $"Failed to load asset : {MainAssetInfo.AssetPath} AssetType : null AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}"; diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledProvider.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledProvider.cs index 3e404b5..c83c453 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledProvider.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledProvider.cs @@ -43,7 +43,7 @@ namespace YooAsset var bundleInfo = new DebugBundleInfo(); bundleInfo.BundleName = OwnerBundle.MainBundleInfo.Bundle.BundleName; bundleInfo.RefCount = OwnerBundle.RefCount; - bundleInfo.Status = (int)OwnerBundle.Status; + bundleInfo.Status = OwnerBundle.Status.ToString(); output.Add(bundleInfo); DependBundleGroup.GetBundleDebugInfos(output); diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledRawFileProvider.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledRawFileProvider.cs index 0dba7ae..4c6401e 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledRawFileProvider.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledRawFileProvider.cs @@ -41,7 +41,7 @@ namespace YooAsset if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed) { - Status = EStatus.Fail; + Status = EStatus.Failed; LastError = OwnerBundle.LastError; InvokeCompletion(); return; @@ -53,7 +53,7 @@ namespace YooAsset if (Status == EStatus.Checking) { RawFilePath = OwnerBundle.FileLoadPath; - Status = EStatus.Success; + Status = EStatus.Succeed; InvokeCompletion(); } } diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledSceneProvider.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledSceneProvider.cs index 1754474..79e36eb 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledSceneProvider.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledSceneProvider.cs @@ -52,7 +52,7 @@ namespace YooAsset if (DependBundleGroup.IsSucceed() == false) { - Status = EStatus.Fail; + Status = EStatus.Failed; LastError = DependBundleGroup.GetLastError(); InvokeCompletion(); return; @@ -60,7 +60,7 @@ namespace YooAsset if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed) { - Status = EStatus.Fail; + Status = EStatus.Failed; LastError = OwnerBundle.LastError; InvokeCompletion(); return; @@ -83,7 +83,7 @@ namespace YooAsset } else { - Status = EStatus.Fail; + Status = EStatus.Failed; LastError = $"Failed to load scene : {_sceneName}"; YooLogger.Error(LastError); InvokeCompletion(); @@ -98,8 +98,8 @@ namespace YooAsset if (SceneObject.IsValid() && _activateOnLoad) SceneManager.SetActiveScene(SceneObject); - Status = SceneObject.IsValid() ? EStatus.Success : EStatus.Fail; - if (Status == EStatus.Fail) + Status = SceneObject.IsValid() ? EStatus.Succeed : EStatus.Failed; + if (Status == EStatus.Failed) { LastError = $"The load scene is invalid : {MainAssetInfo.AssetPath}"; YooLogger.Error(LastError); diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledSubAssetsProvider.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledSubAssetsProvider.cs index 8d317ac..8810ac7 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledSubAssetsProvider.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledSubAssetsProvider.cs @@ -48,7 +48,7 @@ namespace YooAsset if (DependBundleGroup.IsSucceed() == false) { - Status = EStatus.Fail; + Status = EStatus.Failed; LastError = DependBundleGroup.GetLastError(); InvokeCompletion(); return; @@ -56,7 +56,7 @@ namespace YooAsset if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed) { - Status = EStatus.Fail; + Status = EStatus.Failed; LastError = OwnerBundle.LastError; InvokeCompletion(); return; @@ -104,8 +104,8 @@ namespace YooAsset } } - Status = AllAssetObjects == null ? EStatus.Fail : EStatus.Success; - if (Status == EStatus.Fail) + Status = AllAssetObjects == null ? EStatus.Failed : EStatus.Succeed; + if (Status == EStatus.Failed) { if (MainAssetInfo.AssetType == null) LastError = $"Failed to load sub assets : {MainAssetInfo.AssetPath} AssetType : null AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}"; diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/CompletedProvider.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/CompletedProvider.cs index 6f6692a..f9973e1 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Provider/CompletedProvider.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/CompletedProvider.cs @@ -24,7 +24,7 @@ namespace YooAsset { if (Status == EStatus.None) { - Status = EStatus.Fail; + Status = EStatus.Failed; LastError = error; InvokeCompletion(); } diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseAssetProvider.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseAssetProvider.cs index 9ec2f2c..9b2045d 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseAssetProvider.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseAssetProvider.cs @@ -32,7 +32,7 @@ namespace YooAsset string guid = UnityEditor.AssetDatabase.AssetPathToGUID(MainAssetInfo.AssetPath); if (string.IsNullOrEmpty(guid)) { - Status = EStatus.Fail; + Status = EStatus.Failed; LastError = $"Not found asset : {MainAssetInfo.AssetPath}"; YooLogger.Error(LastError); InvokeCompletion(); @@ -59,8 +59,8 @@ namespace YooAsset // 2. 检测加载结果 if (Status == EStatus.Checking) { - Status = AssetObject == null ? EStatus.Fail : EStatus.Success; - if (Status == EStatus.Fail) + Status = AssetObject == null ? EStatus.Failed : EStatus.Succeed; + if (Status == EStatus.Failed) { if (MainAssetInfo.AssetType == null) LastError = $"Failed to load asset object : {MainAssetInfo.AssetPath} AssetType : null"; diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseRawFileProvider.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseRawFileProvider.cs index 87cec4a..380c23e 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseRawFileProvider.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseRawFileProvider.cs @@ -29,7 +29,7 @@ namespace YooAsset string guid = UnityEditor.AssetDatabase.AssetPathToGUID(MainAssetInfo.AssetPath); if (string.IsNullOrEmpty(guid)) { - Status = EStatus.Fail; + Status = EStatus.Failed; LastError = $"Not found asset : {MainAssetInfo.AssetPath}"; YooLogger.Error(LastError); InvokeCompletion(); @@ -46,7 +46,7 @@ namespace YooAsset if(Status == EStatus.Checking) { RawFilePath = MainAssetInfo.AssetPath; - Status = EStatus.Success; + Status = EStatus.Succeed; InvokeCompletion(); } #endif diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseSceneProvider.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseSceneProvider.cs index 02d03c3..c41a998 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseSceneProvider.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseSceneProvider.cs @@ -51,7 +51,7 @@ namespace YooAsset } else { - Status = EStatus.Fail; + Status = EStatus.Failed; LastError = $"Failed to load scene : {MainAssetInfo.AssetPath}"; YooLogger.Error(LastError); InvokeCompletion(); @@ -66,8 +66,8 @@ namespace YooAsset if (SceneObject.IsValid() && _activateOnLoad) SceneManager.SetActiveScene(SceneObject); - Status = SceneObject.IsValid() ? EStatus.Success : EStatus.Fail; - if (Status == EStatus.Fail) + Status = SceneObject.IsValid() ? EStatus.Succeed : EStatus.Failed; + if (Status == EStatus.Failed) { LastError = $"The loaded scene is invalid : {MainAssetInfo.AssetPath}"; YooLogger.Error(LastError); diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseSubAssetsProvider.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseSubAssetsProvider.cs index 52e1536..c3069d9 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseSubAssetsProvider.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseSubAssetsProvider.cs @@ -32,7 +32,7 @@ namespace YooAsset string guid = UnityEditor.AssetDatabase.AssetPathToGUID(MainAssetInfo.AssetPath); if (string.IsNullOrEmpty(guid)) { - Status = EStatus.Fail; + Status = EStatus.Failed; LastError = $"Not found asset : {MainAssetInfo.AssetPath}"; YooLogger.Error(LastError); InvokeCompletion(); @@ -70,8 +70,8 @@ namespace YooAsset // 2. 检测加载结果 if (Status == EStatus.Checking) { - Status = AllAssetObjects == null ? EStatus.Fail : EStatus.Success; - if (Status == EStatus.Fail) + Status = AllAssetObjects == null ? EStatus.Failed : EStatus.Succeed; + if (Status == EStatus.Failed) { if (MainAssetInfo.AssetType == null) LastError = $"Failed to load sub assets : {MainAssetInfo.AssetPath} AssetType : null"; diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/ProviderBase.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/ProviderBase.cs index 6e1c991..598a508 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Provider/ProviderBase.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/ProviderBase.cs @@ -13,8 +13,8 @@ namespace YooAsset CheckBundle, Loading, Checking, - Success, - Fail, + Succeed, + Failed, } /// @@ -80,7 +80,7 @@ namespace YooAsset { get { - return Status == EStatus.Success || Status == EStatus.Fail; + return Status == EStatus.Succeed || Status == EStatus.Failed; } } diff --git a/Assets/YooAsset/Runtime/DiagnosticSystem/DebugBundleInfo.cs b/Assets/YooAsset/Runtime/DiagnosticSystem/DebugBundleInfo.cs index 34af51e..68ef204 100644 --- a/Assets/YooAsset/Runtime/DiagnosticSystem/DebugBundleInfo.cs +++ b/Assets/YooAsset/Runtime/DiagnosticSystem/DebugBundleInfo.cs @@ -25,7 +25,7 @@ namespace YooAsset /// /// 加载状态 /// - public int Status; + public string Status; public int CompareTo(DebugBundleInfo other) { diff --git a/Assets/YooAsset/Runtime/DiagnosticSystem/DebugProviderInfo.cs b/Assets/YooAsset/Runtime/DiagnosticSystem/DebugProviderInfo.cs index ce14e35..389b80e 100644 --- a/Assets/YooAsset/Runtime/DiagnosticSystem/DebugProviderInfo.cs +++ b/Assets/YooAsset/Runtime/DiagnosticSystem/DebugProviderInfo.cs @@ -40,7 +40,7 @@ namespace YooAsset /// /// 加载状态 /// - public int Status; + public string Status; /// /// 依赖的资源包列表