From 7ba40e5c8839da0fd601f9a3b2eb8ff80980e4a0 Mon Sep 17 00:00:00 2001 From: hevinci Date: Mon, 25 Sep 2023 16:21:02 +0800 Subject: [PATCH] fix #171 --- .../Runtime/PackageSystem/ResourcePackage.cs | 46 ++++++++++--------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/Assets/YooAsset/Runtime/PackageSystem/ResourcePackage.cs b/Assets/YooAsset/Runtime/PackageSystem/ResourcePackage.cs index eaedbec..a15cf64 100644 --- a/Assets/YooAsset/Runtime/PackageSystem/ResourcePackage.cs +++ b/Assets/YooAsset/Runtime/PackageSystem/ResourcePackage.cs @@ -368,17 +368,7 @@ namespace YooAsset { DebugCheckInitialize(); AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null); - if (assetInfo.IsInvalid) - { - YooLogger.Warning(assetInfo.Error); - return false; - } - - BundleInfo bundleInfo = _bundleServices.GetBundleInfo(assetInfo); - if (bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromRemote) - return true; - else - return false; + return IsNeedDownloadFromRemoteInternal(assetInfo); } /// @@ -388,17 +378,7 @@ namespace YooAsset public bool IsNeedDownloadFromRemote(AssetInfo assetInfo) { DebugCheckInitialize(); - if (assetInfo.IsInvalid) - { - YooLogger.Warning(assetInfo.Error); - return false; - } - - BundleInfo bundleInfo = _bundleServices.GetBundleInfo(assetInfo); - if (bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromRemote) - return true; - else - return false; + return IsNeedDownloadFromRemoteInternal(assetInfo); } /// @@ -452,6 +432,28 @@ namespace YooAsset string assetPath = _playModeServices.ActiveManifest.TryMappingToAssetPath(location); return string.IsNullOrEmpty(assetPath) == false; } + + private bool IsNeedDownloadFromRemoteInternal(AssetInfo assetInfo) + { + if (assetInfo.IsInvalid) + { + YooLogger.Warning(assetInfo.Error); + return false; + } + + BundleInfo bundleInfo = _bundleServices.GetBundleInfo(assetInfo); + if (bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromRemote) + return true; + + BundleInfo[] depends = _bundleServices.GetAllDependBundleInfos(assetInfo); + foreach (var depend in depends) + { + if (depend.LoadMode == BundleInfo.ELoadMode.LoadFromRemote) + return true; + } + + return false; + } #endregion #region ๅŽŸ็”Ÿๆ–‡ไปถ