mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-22 00:11:41 +00:00
Compare commits
7 Commits
1.4.1-prev
...
1.4.2-prev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
954e76ab33 | ||
|
|
82bda518c9 | ||
|
|
cdc5bcd31f | ||
|
|
61f6d480ae | ||
|
|
df6df3548c | ||
|
|
ac839450e2 | ||
|
|
4fa01e1a29 |
@@ -2,6 +2,13 @@
|
|||||||
|
|
||||||
All notable changes to this package will be documented in this file.
|
All notable changes to this package will be documented in this file.
|
||||||
|
|
||||||
|
## [1.4.2-preview] - 2023-01-03
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- 修复了清单解析异步操作的进度条变化错误。
|
||||||
|
- 修复了更新资源清单错误计算超时时间的问题。
|
||||||
|
|
||||||
## [1.4.1-preview] - 2022-12-26
|
## [1.4.1-preview] - 2022-12-26
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ namespace YooAsset.Editor
|
|||||||
// 4.更新补丁包输出的文件路径
|
// 4.更新补丁包输出的文件路径
|
||||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
||||||
{
|
{
|
||||||
string patchFileName = PatchManifest.CreateBundleFileName(outputNameStyle, bundleInfo.BundleName, bundleInfo.PatchInfo.PatchFileHash, bundleInfo.IsRawFile);
|
string patchFileName = PatchManifestTools.CreateBundleFileName(outputNameStyle, bundleInfo.BundleName, bundleInfo.PatchInfo.PatchFileHash, bundleInfo.IsRawFile);
|
||||||
bundleInfo.PatchInfo.PatchOutputFilePath = $"{packageOutputDirectory}/{patchFileName}";
|
bundleInfo.PatchInfo.PatchOutputFilePath = $"{packageOutputDirectory}/{patchFileName}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ namespace YooAsset
|
|||||||
if (_steps == ESteps.Unpack)
|
if (_steps == ESteps.Unpack)
|
||||||
{
|
{
|
||||||
int failedTryAgain = 1;
|
int failedTryAgain = 1;
|
||||||
var bundleInfo = HostPlayModeImpl.ConvertToUnpackInfo(MainBundleInfo.Bundle);
|
var bundleInfo = PatchManifestTools.GetUnpackInfo(MainBundleInfo.Bundle);
|
||||||
_unpacker = DownloadSystem.BeginDownload(bundleInfo, failedTryAgain);
|
_unpacker = DownloadSystem.BeginDownload(bundleInfo, failedTryAgain);
|
||||||
_steps = ESteps.CheckUnpack;
|
_steps = ESteps.CheckUnpack;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ namespace YooAsset
|
|||||||
if (_steps == ESteps.Unpack)
|
if (_steps == ESteps.Unpack)
|
||||||
{
|
{
|
||||||
int failedTryAgain = 1;
|
int failedTryAgain = 1;
|
||||||
var bundleInfo = HostPlayModeImpl.ConvertToUnpackInfo(MainBundleInfo.Bundle);
|
var bundleInfo = PatchManifestTools.GetUnpackInfo(MainBundleInfo.Bundle);
|
||||||
_unpacker = DownloadSystem.BeginDownload(bundleInfo, failedTryAgain);
|
_unpacker = DownloadSystem.BeginDownload(bundleInfo, failedTryAgain);
|
||||||
_steps = ESteps.CheckUnpack;
|
_steps = ESteps.CheckUnpack;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
URL = url;
|
URL = url;
|
||||||
_timeout = timeout;
|
_timeout = timeout;
|
||||||
|
_latestDownloadBytes = 0;
|
||||||
|
_latestDownloadRealtime = Time.realtimeSinceStartup;
|
||||||
|
|
||||||
_webRequest = new UnityWebRequest(URL, UnityWebRequest.kHttpVerbGET);
|
_webRequest = new UnityWebRequest(URL, UnityWebRequest.kHttpVerbGET);
|
||||||
DownloadHandlerFile handler = new DownloadHandlerFile(savePath);
|
DownloadHandlerFile handler = new DownloadHandlerFile(savePath);
|
||||||
handler.removeFileOnAbort = true;
|
handler.removeFileOnAbort = true;
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ namespace YooAsset
|
|||||||
Manifest.AssetDic.Add(assetPath, patchAsset);
|
Manifest.AssetDic.Add(assetPath, patchAsset);
|
||||||
|
|
||||||
_patchAssetCount--;
|
_patchAssetCount--;
|
||||||
Progress = _patchAssetCount / _progressTotalValue;
|
Progress = 1f - _patchAssetCount / _progressTotalValue;
|
||||||
if (OperationSystem.IsBusy)
|
if (OperationSystem.IsBusy)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -149,7 +149,7 @@ namespace YooAsset
|
|||||||
Manifest.BundleDic.Add(patchBundle.BundleName, patchBundle);
|
Manifest.BundleDic.Add(patchBundle.BundleName, patchBundle);
|
||||||
|
|
||||||
_patchBundleCount--;
|
_patchBundleCount--;
|
||||||
Progress = _patchBundleCount / _progressTotalValue;
|
Progress = 1f - _patchBundleCount / _progressTotalValue;
|
||||||
if (OperationSystem.IsBusy)
|
if (OperationSystem.IsBusy)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static int RequestCount = 0;
|
private static int RequestCount = 0;
|
||||||
private readonly HostPlayModeImpl _impl;
|
private readonly IRemoteServices _remoteServices;
|
||||||
private readonly string _packageName;
|
private readonly string _packageName;
|
||||||
private readonly string _packageVersion;
|
private readonly string _packageVersion;
|
||||||
private readonly int _timeout;
|
private readonly int _timeout;
|
||||||
@@ -20,9 +20,9 @@ namespace YooAsset
|
|||||||
private UnityWebFileRequester _downloader2;
|
private UnityWebFileRequester _downloader2;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
internal DownloadManifestOperation(HostPlayModeImpl impl, string packageName, string packageVersion, int timeout)
|
internal DownloadManifestOperation(IRemoteServices remoteServices, string packageName, string packageVersion, int timeout)
|
||||||
{
|
{
|
||||||
_impl = impl;
|
_remoteServices = remoteServices;
|
||||||
_packageName = packageName;
|
_packageName = packageName;
|
||||||
_packageVersion = packageVersion;
|
_packageVersion = packageVersion;
|
||||||
_timeout = timeout;
|
_timeout = timeout;
|
||||||
@@ -103,9 +103,9 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
// 轮流返回请求地址
|
// 轮流返回请求地址
|
||||||
if (RequestCount % 2 == 0)
|
if (RequestCount % 2 == 0)
|
||||||
return _impl.GetPatchDownloadFallbackURL(fileName);
|
return _remoteServices.GetRemoteFallbackURL(fileName);
|
||||||
else
|
else
|
||||||
return _impl.GetPatchDownloadMainURL(fileName);
|
return _remoteServices.GetRemoteMainURL(fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static int RequestCount = 0;
|
private static int RequestCount = 0;
|
||||||
private readonly HostPlayModeImpl _impl;
|
private readonly IRemoteServices _remoteServices;
|
||||||
private readonly string _packageName;
|
private readonly string _packageName;
|
||||||
private readonly bool _appendTimeTicks;
|
private readonly bool _appendTimeTicks;
|
||||||
private readonly int _timeout;
|
private readonly int _timeout;
|
||||||
@@ -25,9 +25,9 @@ namespace YooAsset
|
|||||||
public string PackageVersion { private set; get; }
|
public string PackageVersion { private set; get; }
|
||||||
|
|
||||||
|
|
||||||
public QueryRemotePackageVersionOperation(HostPlayModeImpl impl, string packageName, bool appendTimeTicks, int timeout)
|
public QueryRemotePackageVersionOperation(IRemoteServices remoteServices, string packageName, bool appendTimeTicks, int timeout)
|
||||||
{
|
{
|
||||||
_impl = impl;
|
_remoteServices = remoteServices;
|
||||||
_packageName = packageName;
|
_packageName = packageName;
|
||||||
_appendTimeTicks = appendTimeTicks;
|
_appendTimeTicks = appendTimeTicks;
|
||||||
_timeout = timeout;
|
_timeout = timeout;
|
||||||
@@ -89,9 +89,9 @@ namespace YooAsset
|
|||||||
|
|
||||||
// 轮流返回请求地址
|
// 轮流返回请求地址
|
||||||
if (RequestCount % 2 == 0)
|
if (RequestCount % 2 == 0)
|
||||||
url = _impl.GetPatchDownloadFallbackURL(fileName);
|
url = _remoteServices.GetRemoteFallbackURL(fileName);
|
||||||
else
|
else
|
||||||
url = _impl.GetPatchDownloadMainURL(fileName);
|
url = _remoteServices.GetRemoteMainURL(fileName);
|
||||||
|
|
||||||
// 在URL末尾添加时间戳
|
// 在URL末尾添加时间戳
|
||||||
if (_appendTimeTicks)
|
if (_appendTimeTicks)
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
_packageName = packageName;
|
_packageName = packageName;
|
||||||
_cacheKey = $"{packageName}-{FileHash}";
|
_cacheKey = $"{packageName}-{FileHash}";
|
||||||
_fileName = PatchManifest.CreateBundleFileName(nameStype, BundleName, FileHash, IsRawFile);
|
_fileName = PatchManifestTools.CreateBundleFileName(nameStype, BundleName, FileHash, IsRawFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -292,28 +292,6 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 生成Bundle文件的正式名称
|
|
||||||
/// </summary>
|
|
||||||
public static string CreateBundleFileName(int nameStyle, string bundleName, string fileHash, bool isRawFile)
|
|
||||||
{
|
|
||||||
if (nameStyle == 1) //HashName
|
|
||||||
{
|
|
||||||
string fileExtension = isRawFile ? YooAssetSettingsData.Setting.RawFileVariant : YooAssetSettingsData.Setting.AssetBundleFileVariant;
|
|
||||||
return StringUtility.Format("{0}.{1}", fileHash, fileExtension);
|
|
||||||
}
|
|
||||||
else if (nameStyle == 4) //BundleName_HashName
|
|
||||||
{
|
|
||||||
string fileName = bundleName.Remove(bundleName.LastIndexOf('.'));
|
|
||||||
string fileExtension = isRawFile ? YooAssetSettingsData.Setting.RawFileVariant : YooAssetSettingsData.Setting.AssetBundleFileVariant;
|
|
||||||
return StringUtility.Format("{0}_{1}.{2}", fileName, fileHash, fileExtension);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new NotImplementedException($"Invalid name style : {nameStyle}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#region 调试方法
|
#region 调试方法
|
||||||
[Conditional("DEBUG")]
|
[Conditional("DEBUG")]
|
||||||
private void DebugCheckLocation(string location)
|
private void DebugCheckLocation(string location)
|
||||||
|
|||||||
@@ -151,5 +151,38 @@ namespace YooAsset
|
|||||||
|
|
||||||
return manifest;
|
return manifest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 生成Bundle文件的正式名称
|
||||||
|
/// </summary>
|
||||||
|
public static string CreateBundleFileName(int nameStyle, string bundleName, string fileHash, bool isRawFile)
|
||||||
|
{
|
||||||
|
if (nameStyle == 1) //HashName
|
||||||
|
{
|
||||||
|
string fileExtension = isRawFile ? YooAssetSettingsData.Setting.RawFileVariant : YooAssetSettingsData.Setting.AssetBundleFileVariant;
|
||||||
|
return StringUtility.Format("{0}.{1}", fileHash, fileExtension);
|
||||||
|
}
|
||||||
|
else if (nameStyle == 4) //BundleName_HashName
|
||||||
|
{
|
||||||
|
string fileName = bundleName.Remove(bundleName.LastIndexOf('.'));
|
||||||
|
string fileExtension = isRawFile ? YooAssetSettingsData.Setting.RawFileVariant : YooAssetSettingsData.Setting.AssetBundleFileVariant;
|
||||||
|
return StringUtility.Format("{0}_{1}.{2}", fileName, fileHash, fileExtension);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new NotImplementedException($"Invalid name style : {nameStyle}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取解压BundleInfo
|
||||||
|
/// </summary>
|
||||||
|
public static BundleInfo GetUnpackInfo(PatchBundle patchBundle)
|
||||||
|
{
|
||||||
|
// 注意:我们把流加载路径指定为远端下载地址
|
||||||
|
string streamingPath = PathHelper.ConvertToWWWPath(patchBundle.StreamingFilePath);
|
||||||
|
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromStreaming, streamingPath, streamingPath);
|
||||||
|
return bundleInfo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
internal class HostPlayModeImpl : IPlayModeServices, IBundleServices
|
internal class HostPlayModeImpl : IPlayModeServices, IBundleServices, IRemoteServices
|
||||||
{
|
{
|
||||||
private PatchManifest _activeManifest;
|
private PatchManifest _activeManifest;
|
||||||
|
|
||||||
@@ -31,16 +31,6 @@ namespace YooAsset
|
|||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
// WEB相关
|
|
||||||
public string GetPatchDownloadMainURL(string fileName)
|
|
||||||
{
|
|
||||||
return $"{_defaultHostServer}/{fileName}";
|
|
||||||
}
|
|
||||||
public string GetPatchDownloadFallbackURL(string fileName)
|
|
||||||
{
|
|
||||||
return $"{_fallbackHostServer}/{fileName}";
|
|
||||||
}
|
|
||||||
|
|
||||||
// 下载相关
|
// 下载相关
|
||||||
private List<BundleInfo> ConvertToDownloadList(List<PatchBundle> downloadList)
|
private List<BundleInfo> ConvertToDownloadList(List<PatchBundle> downloadList)
|
||||||
{
|
{
|
||||||
@@ -54,8 +44,8 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
private BundleInfo ConvertToDownloadInfo(PatchBundle patchBundle)
|
private BundleInfo ConvertToDownloadInfo(PatchBundle patchBundle)
|
||||||
{
|
{
|
||||||
string remoteMainURL = GetPatchDownloadMainURL(patchBundle.FileName);
|
string remoteMainURL = GetRemoteMainURL(patchBundle.FileName);
|
||||||
string remoteFallbackURL = GetPatchDownloadFallbackURL(patchBundle.FileName);
|
string remoteFallbackURL = GetRemoteFallbackURL(patchBundle.FileName);
|
||||||
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromRemote, remoteMainURL, remoteFallbackURL);
|
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromRemote, remoteMainURL, remoteFallbackURL);
|
||||||
return bundleInfo;
|
return bundleInfo;
|
||||||
}
|
}
|
||||||
@@ -71,14 +61,22 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public static BundleInfo ConvertToUnpackInfo(PatchBundle patchBundle)
|
private BundleInfo ConvertToUnpackInfo(PatchBundle patchBundle)
|
||||||
{
|
{
|
||||||
// 注意:我们把流加载路径指定为远端下载地址
|
return PatchManifestTools.GetUnpackInfo(patchBundle);
|
||||||
string streamingPath = PathHelper.ConvertToWWWPath(patchBundle.StreamingFilePath);
|
|
||||||
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromStreaming, streamingPath, streamingPath);
|
|
||||||
return bundleInfo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region IRemoteServices接口
|
||||||
|
public string GetRemoteMainURL(string fileName)
|
||||||
|
{
|
||||||
|
return $"{_defaultHostServer}/{fileName}";
|
||||||
|
}
|
||||||
|
public string GetRemoteFallbackURL(string fileName)
|
||||||
|
{
|
||||||
|
return $"{_fallbackHostServer}/{fileName}";
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region IPlayModeServices接口
|
#region IPlayModeServices接口
|
||||||
public PatchManifest ActiveManifest
|
public PatchManifest ActiveManifest
|
||||||
{
|
{
|
||||||
|
|||||||
9
Assets/YooAsset/Runtime/Services/IRemoteServices.cs
Normal file
9
Assets/YooAsset/Runtime/Services/IRemoteServices.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
internal interface IRemoteServices
|
||||||
|
{
|
||||||
|
string GetRemoteMainURL(string fileName);
|
||||||
|
string GetRemoteFallbackURL(string fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/YooAsset/Runtime/Services/IRemoteServices.cs.meta
Normal file
11
Assets/YooAsset/Runtime/Services/IRemoteServices.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 55b92092303a8d44280c107e6c5a8379
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "com.tuyoogame.yooasset",
|
"name": "com.tuyoogame.yooasset",
|
||||||
"displayName": "YooAsset",
|
"displayName": "YooAsset",
|
||||||
"version": "1.4.1-preview",
|
"version": "1.4.2-preview",
|
||||||
"unity": "2019.4",
|
"unity": "2019.4",
|
||||||
"description": "unity3d resources management system.",
|
"description": "unity3d resources management system.",
|
||||||
"author": {
|
"author": {
|
||||||
|
|||||||
@@ -94,8 +94,6 @@ private class QueryStreamingAssetsFileServices : IQueryServices
|
|||||||
|
|
||||||
- 联机运行模式
|
- 联机运行模式
|
||||||
|
|
||||||
该模式下,每个package都会在沙盒里保留一份清单,当有更新的时候采用覆盖的方式存储。
|
|
||||||
|
|
||||||
在初始化的时候,会优先从沙盒里加载清单,如果沙盒里不存在,则会尝试加载内置清单并将其拷贝到沙盒里。最后根据加载的清单去验证沙盒里缓存的文件。
|
在初始化的时候,会优先从沙盒里加载清单,如果沙盒里不存在,则会尝试加载内置清单并将其拷贝到沙盒里。最后根据加载的清单去验证沙盒里缓存的文件。
|
||||||
|
|
||||||
**注意**:如果沙盒清单和内置清单都不存在,初始化也会被判定为成功!
|
**注意**:如果沙盒清单和内置清单都不存在,初始化也会被判定为成功!
|
||||||
|
|||||||
@@ -130,7 +130,8 @@ private IEnumerator Start()
|
|||||||
{
|
{
|
||||||
// 如果获取远端资源版本失败,说明当前网络无连接。
|
// 如果获取远端资源版本失败,说明当前网络无连接。
|
||||||
// 在正常开始游戏之前,需要验证本地清单内容的完整性。
|
// 在正常开始游戏之前,需要验证本地清单内容的完整性。
|
||||||
var operation = package.CheckPackageContentsAsync();
|
string packageVersion = package.GetPackageVersion();
|
||||||
|
var operation = package.CheckPackageContentsAsync(packageVersion);
|
||||||
yield return operation;
|
yield return operation;
|
||||||
if (operation.Status == EOperationStatus.Succeed)
|
if (operation.Status == EOperationStatus.Succeed)
|
||||||
{
|
{
|
||||||
@@ -147,14 +148,6 @@ private IEnumerator Start()
|
|||||||
|
|
||||||
### 源代码解析
|
### 源代码解析
|
||||||
|
|
||||||
- 编辑器模拟模式
|
|
||||||
|
|
||||||
UpdatePackageVersionAsync()方法和UpdatePackageManifestAsync()方法都不起效,但是都会返回成功!
|
|
||||||
|
|
||||||
- 单机运行模式
|
|
||||||
|
|
||||||
UpdatePackageVersionAsync()方法和UpdatePackageManifestAsync()方法都不起效,但是都会返回成功!
|
|
||||||
|
|
||||||
- 联机运行模式
|
- 联机运行模式
|
||||||
|
|
||||||
UpdatePackageManifestAsync()为资源清单更新方法。该方法的内部实现原理如下:
|
UpdatePackageManifestAsync()为资源清单更新方法。该方法的内部实现原理如下:
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 32 KiB |
Reference in New Issue
Block a user