diff --git a/Assets/YooAsset/Runtime/AssetSystem/AssetSystem.cs b/Assets/YooAsset/Runtime/AssetSystem/AssetSystem.cs index e9badb7..b1fdef6 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/AssetSystem.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/AssetSystem.cs @@ -73,15 +73,15 @@ namespace YooAsset { provider.Destroy(); } + _providers.Clear(); + foreach (var loader in _loaders) { loader.Destroy(true); } - - _providers.Clear(); _loaders.Clear(); - ClearSceneHandle(); + ClearSceneHandle(); DecryptionServices = null; BundleServices = null; } @@ -298,19 +298,21 @@ namespace YooAsset internal void ClearSceneHandle() { // 释放资源包下的所有场景 - string packageName = BundleServices.GetPackageName(); - List removeList = new List(); - foreach (var valuePair in _sceneHandles) + if (BundleServices.IsServicesValid()) { - if (valuePair.Value.PackageName == packageName) + string packageName = BundleServices.GetPackageName(); + List removeList = new List(); + foreach (var valuePair in _sceneHandles) { - removeList.Add(valuePair.Key); + if (valuePair.Value.PackageName == packageName) + { + removeList.Add(valuePair.Key); + } + } + foreach (var key in removeList) + { + _sceneHandles.Remove(key); } - } - - foreach (var key in removeList) - { - _sceneHandles.Remove(key); } } diff --git a/Assets/YooAsset/Runtime/AssetsPackage.cs b/Assets/YooAsset/Runtime/AssetsPackage.cs index 2ce48e2..2fe153e 100644 --- a/Assets/YooAsset/Runtime/AssetsPackage.cs +++ b/Assets/YooAsset/Runtime/AssetsPackage.cs @@ -132,7 +132,7 @@ namespace YooAsset } private void ResetInitializeAfterFailed() { - if(_isInitialize && _initializeStatus == EOperationStatus.Failed) + if (_isInitialize && _initializeStatus == EOperationStatus.Failed) { _isInitialize = false; _initializeStatus = EOperationStatus.None; diff --git a/Assets/YooAsset/Runtime/PatchSystem/PlayMode/EditorSimulateModeImpl.cs b/Assets/YooAsset/Runtime/PatchSystem/PlayMode/EditorSimulateModeImpl.cs index 4a95323..fcdb5ee 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/PlayMode/EditorSimulateModeImpl.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/PlayMode/EditorSimulateModeImpl.cs @@ -78,6 +78,10 @@ namespace YooAsset { return _simulatePatchManifest.IsIncludeBundleFile(fileName); } + bool IBundleServices.IsServicesValid() + { + return _simulatePatchManifest != null; + } #endregion } } \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/PatchSystem/PlayMode/HostPlayModeImpl.cs b/Assets/YooAsset/Runtime/PatchSystem/PlayMode/HostPlayModeImpl.cs index 7c10a97..39a8d88 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/PlayMode/HostPlayModeImpl.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/PlayMode/HostPlayModeImpl.cs @@ -428,6 +428,10 @@ namespace YooAsset { return LocalPatchManifest.IsIncludeBundleFile(fileName); } + bool IBundleServices.IsServicesValid() + { + return LocalPatchManifest != null; + } #endregion } } \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/PatchSystem/PlayMode/OfflinePlayModeImpl.cs b/Assets/YooAsset/Runtime/PatchSystem/PlayMode/OfflinePlayModeImpl.cs index 5e77346..b38e3bb 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/PlayMode/OfflinePlayModeImpl.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/PlayMode/OfflinePlayModeImpl.cs @@ -129,6 +129,10 @@ namespace YooAsset { return _appPatchManifest.IsIncludeBundleFile(fileName); } + bool IBundleServices.IsServicesValid() + { + return _appPatchManifest != null; + } #endregion } } \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/Services/IBundleServices.cs b/Assets/YooAsset/Runtime/Services/IBundleServices.cs index 8198d72..eaaf197 100644 --- a/Assets/YooAsset/Runtime/Services/IBundleServices.cs +++ b/Assets/YooAsset/Runtime/Services/IBundleServices.cs @@ -2,7 +2,7 @@ namespace YooAsset { internal interface IBundleServices - { + { /// /// 获取资源包信息 /// @@ -42,5 +42,10 @@ namespace YooAsset /// 是否包含资源文件 /// bool IsIncludeBundleFile(string fileName); + + /// + /// 服务接口是否有效 + /// + bool IsServicesValid(); } } \ No newline at end of file