From c32e7bc5258dc252b745d687f3f75a0b8fdda721 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E5=86=A0=E5=B3=B0?= Date: Fri, 17 Jan 2025 15:21:35 +0800 Subject: [PATCH] Update YooAssets.cs --- Assets/YooAsset/Runtime/YooAssets.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Assets/YooAsset/Runtime/YooAssets.cs b/Assets/YooAsset/Runtime/YooAssets.cs index 8a762d70..cb0f5c7b 100644 --- a/Assets/YooAsset/Runtime/YooAssets.cs +++ b/Assets/YooAsset/Runtime/YooAssets.cs @@ -131,6 +131,17 @@ namespace YooAsset if (package == null) return false; + return RemovePackage(package); + } + + /// + /// 移除资源包 + /// + /// 资源包实例对象 + public static bool RemovePackage(ResourcePackage package) + { + CheckException(package); + string packageName = package.PackageName; if (package.InitializeStatus != EOperationStatus.None) { YooLogger.Error($"The resource package {packageName} has not been destroyed, please call the method {nameof(ResourcePackage.DestroyAsync)} to destroy!"); @@ -181,6 +192,14 @@ namespace YooAsset if (string.IsNullOrEmpty(packageName)) throw new Exception("Package name is null or empty !"); } + private static void CheckException(ResourcePackage package) + { + if (_isInitialize == false) + throw new Exception($"{nameof(YooAssets)} not initialize !"); + + if (package == null) + throw new Exception("Package instance is null !"); + } #region 系统参数 ///