From c10ac0b41ca116992cff319f4d03132b257aa906 Mon Sep 17 00:00:00 2001 From: hevinci Date: Mon, 26 Jun 2023 10:42:56 +0800 Subject: [PATCH] update runtime code --- .../Loader/AssetBundleFileLoader.cs | 2 +- .../AssetSystem/Loader/RawBundleFileLoader.cs | 2 +- .../AssetSystem/Loader/RawBundleWebLoader.cs | 2 +- .../Runtime/PackageSystem/ManifestTools.cs | 19 +++++++++++++++--- .../PlayMode/HostPlayModeImpl.cs | 20 ++----------------- .../PlayMode/OfflinePlayModeImpl.cs | 20 ++----------------- 6 files changed, 23 insertions(+), 42 deletions(-) diff --git a/Assets/YooAsset/Runtime/AssetSystem/Loader/AssetBundleFileLoader.cs b/Assets/YooAsset/Runtime/AssetSystem/Loader/AssetBundleFileLoader.cs index 851d61d..85f8687 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Loader/AssetBundleFileLoader.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Loader/AssetBundleFileLoader.cs @@ -111,7 +111,7 @@ namespace YooAsset if (_steps == ESteps.Unpack) { int failedTryAgain = Impl.DownloadFailedTryAgain; - var bundleInfo = ManifestTools.GetUnpackInfo(MainBundleInfo.Bundle); + var bundleInfo = ManifestTools.ConvertToUnpackInfo(MainBundleInfo.Bundle); _unpacker = DownloadSystem.BeginDownload(bundleInfo, failedTryAgain); _steps = ESteps.CheckUnpack; } diff --git a/Assets/YooAsset/Runtime/AssetSystem/Loader/RawBundleFileLoader.cs b/Assets/YooAsset/Runtime/AssetSystem/Loader/RawBundleFileLoader.cs index 6c8d5bf..463e75d 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Loader/RawBundleFileLoader.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Loader/RawBundleFileLoader.cs @@ -92,7 +92,7 @@ namespace YooAsset if (_steps == ESteps.Unpack) { int failedTryAgain = Impl.DownloadFailedTryAgain; - var bundleInfo = ManifestTools.GetUnpackInfo(MainBundleInfo.Bundle); + var bundleInfo = ManifestTools.ConvertToUnpackInfo(MainBundleInfo.Bundle); _unpacker = DownloadSystem.BeginDownload(bundleInfo, failedTryAgain); _steps = ESteps.CheckUnpack; } diff --git a/Assets/YooAsset/Runtime/AssetSystem/Loader/RawBundleWebLoader.cs b/Assets/YooAsset/Runtime/AssetSystem/Loader/RawBundleWebLoader.cs index 5d6356f..228c224 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Loader/RawBundleWebLoader.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Loader/RawBundleWebLoader.cs @@ -90,7 +90,7 @@ namespace YooAsset if (_steps == ESteps.Website) { int failedTryAgain = Impl.DownloadFailedTryAgain; - var bundleInfo = ManifestTools.GetUnpackInfo(MainBundleInfo.Bundle); + var bundleInfo = ManifestTools.ConvertToUnpackInfo(MainBundleInfo.Bundle); _website = DownloadSystem.BeginDownload(bundleInfo, failedTryAgain); _steps = ESteps.CheckWebsite; } diff --git a/Assets/YooAsset/Runtime/PackageSystem/ManifestTools.cs b/Assets/YooAsset/Runtime/PackageSystem/ManifestTools.cs index 7ae3b36..40a4a0c 100644 --- a/Assets/YooAsset/Runtime/PackageSystem/ManifestTools.cs +++ b/Assets/YooAsset/Runtime/PackageSystem/ManifestTools.cs @@ -8,7 +8,6 @@ namespace YooAsset { internal static class ManifestTools { - #if UNITY_EDITOR /// /// 序列化(JSON文件) @@ -188,14 +187,28 @@ namespace YooAsset } /// - /// 获取解压BundleInfo + /// 转换为解压BundleInfo /// - public static BundleInfo GetUnpackInfo(PackageBundle packageBundle) + public static BundleInfo ConvertToUnpackInfo(PackageBundle packageBundle) { // 注意:我们把流加载路径指定为远端下载地址 string streamingPath = PersistentTools.ConvertToWWWPath(packageBundle.StreamingFilePath); BundleInfo bundleInfo = new BundleInfo(packageBundle, BundleInfo.ELoadMode.LoadFromStreaming, streamingPath, streamingPath); return bundleInfo; } + + /// + /// 批量转换解压为BundleInfo + /// + public static List ConvertToUnpackInfos(List unpackList) + { + List result = new List(unpackList.Count); + foreach (var packageBundle in unpackList) + { + var bundleInfo = ConvertToUnpackInfo(packageBundle); + result.Add(bundleInfo); + } + return result; + } } } \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/PackageSystem/PlayMode/HostPlayModeImpl.cs b/Assets/YooAsset/Runtime/PackageSystem/PlayMode/HostPlayModeImpl.cs index 0687fcc..d0f5d50 100644 --- a/Assets/YooAsset/Runtime/PackageSystem/PlayMode/HostPlayModeImpl.cs +++ b/Assets/YooAsset/Runtime/PackageSystem/PlayMode/HostPlayModeImpl.cs @@ -50,22 +50,6 @@ namespace YooAsset return bundleInfo; } - // 解压相关 - private List ConvertToUnpackList(List unpackList) - { - List result = new List(unpackList.Count); - foreach (var packageBundle in unpackList) - { - var bundleInfo = ConvertToUnpackInfo(packageBundle); - result.Add(bundleInfo); - } - return result; - } - private BundleInfo ConvertToUnpackInfo(PackageBundle packageBundle) - { - return ManifestTools.GetUnpackInfo(packageBundle); - } - #region IRemoteServices接口 public string GetRemoteMainURL(string fileName) { @@ -256,7 +240,7 @@ namespace YooAsset } } - return ConvertToUnpackList(downloadList); + return ManifestTools.ConvertToUnpackInfos(downloadList); } ResourceUnpackerOperation IPlayModeServices.CreateResourceUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout) @@ -284,7 +268,7 @@ namespace YooAsset } } - return ConvertToUnpackList(downloadList); + return ManifestTools.ConvertToUnpackInfos(downloadList); } #endregion diff --git a/Assets/YooAsset/Runtime/PackageSystem/PlayMode/OfflinePlayModeImpl.cs b/Assets/YooAsset/Runtime/PackageSystem/PlayMode/OfflinePlayModeImpl.cs index 563399f..4b12d38 100644 --- a/Assets/YooAsset/Runtime/PackageSystem/PlayMode/OfflinePlayModeImpl.cs +++ b/Assets/YooAsset/Runtime/PackageSystem/PlayMode/OfflinePlayModeImpl.cs @@ -20,22 +20,6 @@ namespace YooAsset return operation; } - // 解压相关 - private List ConvertToUnpackList(List unpackList) - { - List result = new List(unpackList.Count); - foreach (var packageBundle in unpackList) - { - var bundleInfo = ConvertToUnpackInfo(packageBundle); - result.Add(bundleInfo); - } - return result; - } - private BundleInfo ConvertToUnpackInfo(PackageBundle packageBundle) - { - return ManifestTools.GetUnpackInfo(packageBundle); - } - #region IPlayModeServices接口 public PackageManifest ActiveManifest { @@ -108,7 +92,7 @@ namespace YooAsset downloadList.Add(packageBundle); } - return ConvertToUnpackList(downloadList); + return ManifestTools.ConvertToUnpackInfos(downloadList); } ResourceUnpackerOperation IPlayModeServices.CreateResourceUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout) @@ -133,7 +117,7 @@ namespace YooAsset } } - return ConvertToUnpackList(downloadList); + return ManifestTools.ConvertToUnpackInfos(downloadList); } #endregion