From eb98eaeb3b49246fa8db1241c40bbdfe4da47542 Mon Sep 17 00:00:00 2001 From: hevinci Date: Mon, 25 Sep 2023 16:30:24 +0800 Subject: [PATCH] update resource package --- .../ResourceManager/ResourceManager.cs | 2 +- .../ResourcePackage/Interface/IBundleQuery.cs | 2 +- .../PlayMode/EditorSimulateModeImpl.cs | 2 +- .../PlayMode/HostPlayModeImpl.cs | 2 +- .../PlayMode/OfflinePlayModeImpl.cs | 2 +- .../PlayMode/WebPlayModeImpl.cs | 2 +- .../ResourcePackage/ResourcePackage.cs | 46 ++++++++++--------- 7 files changed, 30 insertions(+), 28 deletions(-) diff --git a/Assets/YooAsset/Runtime/ResourceManager/ResourceManager.cs b/Assets/YooAsset/Runtime/ResourceManager/ResourceManager.cs index 77ca442..b3ee19f 100644 --- a/Assets/YooAsset/Runtime/ResourceManager/ResourceManager.cs +++ b/Assets/YooAsset/Runtime/ResourceManager/ResourceManager.cs @@ -348,7 +348,7 @@ namespace YooAsset } internal List CreateDependAssetBundleLoaders(AssetInfo assetInfo) { - BundleInfo[] depends = _bundleQuery.GetAllDependBundleInfos(assetInfo); + BundleInfo[] depends = _bundleQuery.GetDependBundleInfos(assetInfo); List result = new List(depends.Length); foreach (var bundleInfo in depends) { diff --git a/Assets/YooAsset/Runtime/ResourcePackage/Interface/IBundleQuery.cs b/Assets/YooAsset/Runtime/ResourcePackage/Interface/IBundleQuery.cs index 7e076cd..b0b5578 100644 --- a/Assets/YooAsset/Runtime/ResourcePackage/Interface/IBundleQuery.cs +++ b/Assets/YooAsset/Runtime/ResourcePackage/Interface/IBundleQuery.cs @@ -11,7 +11,7 @@ namespace YooAsset /// /// 获取依赖的资源包信息集合 /// - BundleInfo[] GetAllDependBundleInfos(AssetInfo assetPath); + BundleInfo[] GetDependBundleInfos(AssetInfo assetPath); /// /// 清单是否有效 diff --git a/Assets/YooAsset/Runtime/ResourcePackage/PlayMode/EditorSimulateModeImpl.cs b/Assets/YooAsset/Runtime/ResourcePackage/PlayMode/EditorSimulateModeImpl.cs index 6741377..bef47e1 100644 --- a/Assets/YooAsset/Runtime/ResourcePackage/PlayMode/EditorSimulateModeImpl.cs +++ b/Assets/YooAsset/Runtime/ResourcePackage/PlayMode/EditorSimulateModeImpl.cs @@ -111,7 +111,7 @@ namespace YooAsset var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath); return CreateBundleInfo(packageBundle, assetInfo); } - BundleInfo[] IBundleQuery.GetAllDependBundleInfos(AssetInfo assetInfo) + BundleInfo[] IBundleQuery.GetDependBundleInfos(AssetInfo assetInfo) { if (assetInfo.IsInvalid) throw new Exception("Should never get here !"); diff --git a/Assets/YooAsset/Runtime/ResourcePackage/PlayMode/HostPlayModeImpl.cs b/Assets/YooAsset/Runtime/ResourcePackage/PlayMode/HostPlayModeImpl.cs index 4c375be..d1862e1 100644 --- a/Assets/YooAsset/Runtime/ResourcePackage/PlayMode/HostPlayModeImpl.cs +++ b/Assets/YooAsset/Runtime/ResourcePackage/PlayMode/HostPlayModeImpl.cs @@ -366,7 +366,7 @@ namespace YooAsset var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath); return CreateBundleInfo(packageBundle); } - BundleInfo[] IBundleQuery.GetAllDependBundleInfos(AssetInfo assetInfo) + BundleInfo[] IBundleQuery.GetDependBundleInfos(AssetInfo assetInfo) { if (assetInfo.IsInvalid) throw new Exception("Should never get here !"); diff --git a/Assets/YooAsset/Runtime/ResourcePackage/PlayMode/OfflinePlayModeImpl.cs b/Assets/YooAsset/Runtime/ResourcePackage/PlayMode/OfflinePlayModeImpl.cs index f182bb8..6c1d34b 100644 --- a/Assets/YooAsset/Runtime/ResourcePackage/PlayMode/OfflinePlayModeImpl.cs +++ b/Assets/YooAsset/Runtime/ResourcePackage/PlayMode/OfflinePlayModeImpl.cs @@ -195,7 +195,7 @@ namespace YooAsset var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath); return CreateBundleInfo(packageBundle); } - BundleInfo[] IBundleQuery.GetAllDependBundleInfos(AssetInfo assetInfo) + BundleInfo[] IBundleQuery.GetDependBundleInfos(AssetInfo assetInfo) { if (assetInfo.IsInvalid) throw new Exception("Should never get here !"); diff --git a/Assets/YooAsset/Runtime/ResourcePackage/PlayMode/WebPlayModeImpl.cs b/Assets/YooAsset/Runtime/ResourcePackage/PlayMode/WebPlayModeImpl.cs index 4c7087d..5d59fa7 100644 --- a/Assets/YooAsset/Runtime/ResourcePackage/PlayMode/WebPlayModeImpl.cs +++ b/Assets/YooAsset/Runtime/ResourcePackage/PlayMode/WebPlayModeImpl.cs @@ -144,7 +144,7 @@ namespace YooAsset var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath); return CreateBundleInfo(packageBundle); } - BundleInfo[] IBundleQuery.GetAllDependBundleInfos(AssetInfo assetInfo) + BundleInfo[] IBundleQuery.GetDependBundleInfos(AssetInfo assetInfo) { if (assetInfo.IsInvalid) throw new Exception("Should never get here !"); diff --git a/Assets/YooAsset/Runtime/ResourcePackage/ResourcePackage.cs b/Assets/YooAsset/Runtime/ResourcePackage/ResourcePackage.cs index 8da7364..f3f31bc 100644 --- a/Assets/YooAsset/Runtime/ResourcePackage/ResourcePackage.cs +++ b/Assets/YooAsset/Runtime/ResourcePackage/ResourcePackage.cs @@ -403,17 +403,7 @@ namespace YooAsset { DebugCheckInitialize(); AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null); - if (assetInfo.IsInvalid) - { - YooLogger.Warning(assetInfo.Error); - return false; - } - - BundleInfo bundleInfo = _bundleQuery.GetMainBundleInfo(assetInfo); - if (bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromRemote) - return true; - else - return false; + return IsNeedDownloadFromRemoteInternal(assetInfo); } /// @@ -423,17 +413,7 @@ namespace YooAsset public bool IsNeedDownloadFromRemote(AssetInfo assetInfo) { DebugCheckInitialize(); - if (assetInfo.IsInvalid) - { - YooLogger.Warning(assetInfo.Error); - return false; - } - - BundleInfo bundleInfo = _bundleQuery.GetMainBundleInfo(assetInfo); - if (bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromRemote) - return true; - else - return false; + return IsNeedDownloadFromRemoteInternal(assetInfo); } /// @@ -487,6 +467,28 @@ namespace YooAsset string assetPath = _playModeImpl.ActiveManifest.TryMappingToAssetPath(location); return string.IsNullOrEmpty(assetPath) == false; } + + private bool IsNeedDownloadFromRemoteInternal(AssetInfo assetInfo) + { + if (assetInfo.IsInvalid) + { + YooLogger.Warning(assetInfo.Error); + return false; + } + + BundleInfo bundleInfo = _bundleQuery.GetMainBundleInfo(assetInfo); + if (bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromRemote) + return true; + + BundleInfo[] depends = _bundleQuery.GetDependBundleInfos(assetInfo); + foreach (var depend in depends) + { + if (depend.LoadMode == BundleInfo.ELoadMode.LoadFromRemote) + return true; + } + + return false; + } #endregion #region 原生文件