Update runtime code

UpdateStaticVersionOperation.PackageCRC重名为PackageVersion。
AssetPackage.GetHumanReadableVersion()重名为GetPackageVersion()
pull/51/head
hevinci 2022-10-26 21:02:25 +08:00
parent 18426d0481
commit cc04efe76b
12 changed files with 143 additions and 117 deletions

View File

@ -212,9 +212,9 @@ namespace YooAsset
/// <summary> /// <summary>
/// 向网络端请求并更新补丁清单 /// 向网络端请求并更新补丁清单
/// </summary> /// </summary>
/// <param name="packageCRC">更新的资源包裹版本</param> /// <param name="packageVersion">更新的包裹版本</param>
/// <param name="timeout">超时时间默认值60秒</param> /// <param name="timeout">超时时间默认值60秒</param>
public UpdateManifestOperation UpdateManifestAsync(string packageCRC, int timeout = 60) public UpdateManifestOperation UpdateManifestAsync(string packageVersion, int timeout = 60)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
DebugCheckUpdateManifest(); DebugCheckUpdateManifest();
@ -232,7 +232,7 @@ namespace YooAsset
} }
else if (_playMode == EPlayMode.HostPlayMode) else if (_playMode == EPlayMode.HostPlayMode)
{ {
return _hostPlayModeImpl.UpdatePatchManifestAsync(PackageName, packageCRC, timeout); return _hostPlayModeImpl.UpdatePatchManifestAsync(PackageName, packageVersion, timeout);
} }
else else
{ {
@ -244,8 +244,8 @@ namespace YooAsset
/// 弱联网情况下加载补丁清单 /// 弱联网情况下加载补丁清单
/// 注意:当指定版本内容验证失败后会返回失败。 /// 注意:当指定版本内容验证失败后会返回失败。
/// </summary> /// </summary>
/// <param name="packageCRC">指定的资源包裹版本</param> /// <param name="packageVersion">指定的包裹版本</param>
public UpdateManifestOperation WeaklyUpdateManifestAsync(string packageCRC) public UpdateManifestOperation WeaklyUpdateManifestAsync(string packageVersion)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
if (_playMode == EPlayMode.EditorSimulateMode) if (_playMode == EPlayMode.EditorSimulateMode)
@ -262,7 +262,7 @@ namespace YooAsset
} }
else if (_playMode == EPlayMode.HostPlayMode) else if (_playMode == EPlayMode.HostPlayMode)
{ {
return _hostPlayModeImpl.WeaklyUpdatePatchManifestAsync(PackageName, packageCRC); return _hostPlayModeImpl.WeaklyUpdatePatchManifestAsync(PackageName, packageVersion);
} }
else else
{ {
@ -271,22 +271,22 @@ namespace YooAsset
} }
/// <summary> /// <summary>
/// 获取人类可读的版本信息 /// 获取包裹的版本信息
/// </summary> /// </summary>
public string GetHumanReadableVersion() public string GetPackageVersion()
{ {
DebugCheckInitialize(); DebugCheckInitialize();
if (_playMode == EPlayMode.EditorSimulateMode) if (_playMode == EPlayMode.EditorSimulateMode)
{ {
return _editorSimulateModeImpl.GetHumanReadableVersion(); return _editorSimulateModeImpl.GetPackageVersion();
} }
else if (_playMode == EPlayMode.OfflinePlayMode) else if (_playMode == EPlayMode.OfflinePlayMode)
{ {
return _offlinePlayModeImpl.GetHumanReadableVersion(); return _offlinePlayModeImpl.GetPackageVersion();
} }
else if (_playMode == EPlayMode.HostPlayMode) else if (_playMode == EPlayMode.HostPlayMode)
{ {
return _hostPlayModeImpl.GetHumanReadableVersion(); return _hostPlayModeImpl.GetPackageVersion();
} }
else else
{ {
@ -898,9 +898,9 @@ namespace YooAsset
/// <summary> /// <summary>
/// 创建资源包裹下载器,用于下载更新指定资源版本所有的资源包文件 /// 创建资源包裹下载器,用于下载更新指定资源版本所有的资源包文件
/// </summary> /// </summary>
/// <param name="packageCRC">指定更新的资源包裹版本</param> /// <param name="packageVersion">指定更新的包裹版本</param>
/// <param name="timeout">超时时间</param> /// <param name="timeout">超时时间</param>
public UpdatePackageOperation UpdatePackageAsync(string packageCRC, int timeout = 60) public UpdatePackageOperation UpdatePackageAsync(string packageVersion, int timeout = 60)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
if (_playMode == EPlayMode.EditorSimulateMode) if (_playMode == EPlayMode.EditorSimulateMode)
@ -917,7 +917,7 @@ namespace YooAsset
} }
else if (_playMode == EPlayMode.HostPlayMode) else if (_playMode == EPlayMode.HostPlayMode)
{ {
return _hostPlayModeImpl.UpdatePackageAsync(PackageName, packageCRC, timeout); return _hostPlayModeImpl.UpdatePackageAsync(PackageName, packageVersion, timeout);
} }
else else
{ {

View File

@ -173,10 +173,11 @@ namespace YooAsset
Done, Done,
} }
private string _buildinPackageName; private readonly string _buildinPackageName;
private ESteps _steps = ESteps.LoadStaticVersion; private ESteps _steps = ESteps.LoadStaticVersion;
private UnityWebDataRequester _downloader1; private UnityWebDataRequester _downloader1;
private UnityWebDataRequester _downloader2; private UnityWebDataRequester _downloader2;
private string _buildinPackageVersion;
/// <summary> /// <summary>
/// 错误日志 /// 错误日志
@ -188,11 +189,6 @@ namespace YooAsset
/// </summary> /// </summary>
public PatchManifest Result { private set; get; } public PatchManifest Result { private set; get; }
/// <summary>
/// 内置补丁清单CRC
/// </summary>
public string BuildinPackageCRC { private set; get; }
public AppManifestLoader(string buildinPackageName) public AppManifestLoader(string buildinPackageName)
{ {
@ -227,7 +223,7 @@ namespace YooAsset
if (_steps == ESteps.LoadStaticVersion) if (_steps == ESteps.LoadStaticVersion)
{ {
string fileName = YooAssetSettingsData.GetStaticVersionFileName(_buildinPackageName); string fileName = YooAssetSettingsData.GetPatchManifestVersionFileName(_buildinPackageName);
string filePath = PathHelper.MakeStreamingLoadPath(fileName); string filePath = PathHelper.MakeStreamingLoadPath(fileName);
string url = PathHelper.ConvertToWWWPath(filePath); string url = PathHelper.ConvertToWWWPath(filePath);
_downloader1 = new UnityWebDataRequester(); _downloader1 = new UnityWebDataRequester();
@ -248,15 +244,23 @@ namespace YooAsset
} }
else else
{ {
BuildinPackageCRC = _downloader1.GetText(); _buildinPackageVersion = _downloader1.GetText();
if (string.IsNullOrEmpty(_buildinPackageVersion))
{
Error = $"Buildin package version is empty !";
_steps = ESteps.Done;
}
else
{
_steps = ESteps.LoadAppManifest; _steps = ESteps.LoadAppManifest;
} }
}
_downloader1.Dispose(); _downloader1.Dispose();
} }
if (_steps == ESteps.LoadAppManifest) if (_steps == ESteps.LoadAppManifest)
{ {
string fileName = YooAssetSettingsData.GetPatchManifestFileName(_buildinPackageName, BuildinPackageCRC); string fileName = YooAssetSettingsData.GetPatchManifestFileName(_buildinPackageName, _buildinPackageVersion);
string filePath = PathHelper.MakeStreamingLoadPath(fileName); string filePath = PathHelper.MakeStreamingLoadPath(fileName);
string url = PathHelper.ConvertToWWWPath(filePath); string url = PathHelper.ConvertToWWWPath(filePath);
_downloader2 = new UnityWebDataRequester(); _downloader2 = new UnityWebDataRequester();
@ -299,7 +303,7 @@ namespace YooAsset
} }
private string _buildinPackageName; private string _buildinPackageName;
private string _buildinPackageCRC; private string _buildinPackageVersion;
private ESteps _steps = ESteps.CopyAppManifest; private ESteps _steps = ESteps.CopyAppManifest;
private UnityWebFileRequester _downloader1; private UnityWebFileRequester _downloader1;
@ -314,10 +318,10 @@ namespace YooAsset
public bool Result { private set; get; } public bool Result { private set; get; }
public AppManifestCopyer(string buildinPackageName, string buildinPackageCRC) public AppManifestCopyer(string buildinPackageName, string buildinPackageVersion)
{ {
_buildinPackageName = buildinPackageName; _buildinPackageName = buildinPackageName;
_buildinPackageCRC = buildinPackageCRC; _buildinPackageVersion = buildinPackageVersion;
} }
/// <summary> /// <summary>
@ -330,7 +334,7 @@ namespace YooAsset
if (_steps == ESteps.CopyAppManifest) if (_steps == ESteps.CopyAppManifest)
{ {
string fileName = YooAssetSettingsData.GetPatchManifestFileName(_buildinPackageName, _buildinPackageCRC); string fileName = YooAssetSettingsData.GetPatchManifestFileName(_buildinPackageName, _buildinPackageVersion);
string destFilePath = PathHelper.MakePersistentLoadPath(fileName); string destFilePath = PathHelper.MakePersistentLoadPath(fileName);
if (File.Exists(destFilePath)) if (File.Exists(destFilePath))
{ {

View File

@ -52,7 +52,8 @@ namespace YooAsset
private enum ESteps private enum ESteps
{ {
None, None,
CheckManifestHash, LoadWebHash,
CheckWebHash,
LoadWebManifest, LoadWebManifest,
CheckWebManifest, CheckWebManifest,
InitVerifyingCache, InitVerifyingCache,
@ -63,18 +64,19 @@ namespace YooAsset
private static int RequestCount = 0; private static int RequestCount = 0;
private readonly HostPlayModeImpl _impl; private readonly HostPlayModeImpl _impl;
private readonly string _packageName; private readonly string _packageName;
private readonly string _packageCRC; private readonly string _packageVersion;
private readonly int _timeout; private readonly int _timeout;
private UnityWebDataRequester _downloader; private UnityWebDataRequester _downloader1;
private UnityWebDataRequester _downloader2;
private CacheVerifier _cacheVerifier; private CacheVerifier _cacheVerifier;
private ESteps _steps = ESteps.None; private ESteps _steps = ESteps.None;
private float _verifyTime; private float _verifyTime;
internal HostPlayModeUpdateManifestOperation(HostPlayModeImpl impl, string packageName, string packageCRC, int timeout) internal HostPlayModeUpdateManifestOperation(HostPlayModeImpl impl, string packageName, string packageVersion, int timeout)
{ {
_impl = impl; _impl = impl;
_packageName = packageName; _packageName = packageName;
_packageCRC = packageCRC; _packageVersion = packageVersion;
_timeout = timeout; _timeout = timeout;
#if UNITY_WEBGL #if UNITY_WEBGL
@ -86,59 +88,84 @@ namespace YooAsset
internal override void Start() internal override void Start()
{ {
RequestCount++; RequestCount++;
_steps = ESteps.CheckManifestHash; _steps = ESteps.LoadWebHash;
} }
internal override void Update() internal override void Update()
{ {
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
return; return;
if (_steps == ESteps.CheckManifestHash) if (_steps == ESteps.LoadWebHash)
{ {
string cachedManifestCRC = GetSandboxPatchManifestFileHash(_packageName, _packageCRC); string fileName = YooAssetSettingsData.GetPatchManifestHashFileName(_packageName, _packageVersion);
string webURL = GetPatchManifestRequestURL(fileName);
YooLogger.Log($"Beginning to request patch manifest hash : {webURL}");
_downloader1 = new UnityWebDataRequester();
_downloader1.SendRequest(webURL, _timeout);
_steps = ESteps.CheckWebHash;
}
if (_steps == ESteps.CheckWebHash)
{
if (_downloader1.IsDone() == false)
return;
// Check error
if (_downloader1.HasError())
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = _downloader1.GetError();
}
else
{
string webManifestHash = _downloader1.GetText();
string cachedManifestHash = GetSandboxPatchManifestFileHash(_packageName, _packageVersion);
// 如果补丁清单文件的哈希值相同 // 如果补丁清单文件的哈希值相同
if (cachedManifestCRC == _packageCRC) if (cachedManifestHash == webManifestHash)
{ {
YooLogger.Log($"Patch manifest file hash is not change : {_packageCRC}"); YooLogger.Log($"Patch manifest file hash is not change : {webManifestHash}");
LoadSandboxPatchManifest(_packageName, _packageCRC); LoadSandboxPatchManifest(_packageName, _packageVersion);
FoundNewManifest = false; FoundNewManifest = false;
_steps = ESteps.InitVerifyingCache; _steps = ESteps.InitVerifyingCache;
} }
else else
{ {
YooLogger.Log($"Patch manifest hash is change : {cachedManifestCRC} -> {_packageCRC}"); YooLogger.Log($"Patch manifest hash is change : {cachedManifestHash} -> {webManifestHash}");
FoundNewManifest = true; FoundNewManifest = true;
_steps = ESteps.LoadWebManifest; _steps = ESteps.LoadWebManifest;
} }
} }
_downloader1.Dispose();
}
if (_steps == ESteps.LoadWebManifest) if (_steps == ESteps.LoadWebManifest)
{ {
string fileName = YooAssetSettingsData.GetPatchManifestFileName(_packageName, _packageCRC); string fileName = YooAssetSettingsData.GetPatchManifestFileName(_packageName, _packageVersion);
string webURL = GetPatchManifestRequestURL(fileName); string webURL = GetPatchManifestRequestURL(fileName);
YooLogger.Log($"Beginning to request patch manifest : {webURL}"); YooLogger.Log($"Beginning to request patch manifest : {webURL}");
_downloader = new UnityWebDataRequester(); _downloader2 = new UnityWebDataRequester();
_downloader.SendRequest(webURL, _timeout); _downloader2.SendRequest(webURL, _timeout);
_steps = ESteps.CheckWebManifest; _steps = ESteps.CheckWebManifest;
} }
if (_steps == ESteps.CheckWebManifest) if (_steps == ESteps.CheckWebManifest)
{ {
if (_downloader.IsDone() == false) if (_downloader2.IsDone() == false)
return; return;
// Check error // Check error
if (_downloader.HasError()) if (_downloader2.HasError())
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = _downloader.GetError(); Error = _downloader2.GetError();
} }
else else
{ {
// 解析补丁清单 // 解析补丁清单
if (ParseAndSaveRemotePatchManifest(_packageName, _packageCRC, _downloader.GetText())) if (ParseAndSaveRemotePatchManifest(_packageName, _packageVersion, _downloader2.GetText()))
{ {
_steps = ESteps.InitVerifyingCache; _steps = ESteps.InitVerifyingCache;
} }
@ -146,10 +173,10 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = $"URL : {_downloader.URL} Error : remote patch manifest content is invalid"; Error = $"URL : {_downloader2.URL} Error : remote patch manifest content is invalid";
} }
} }
_downloader.Dispose(); _downloader2.Dispose();
} }
if (_steps == ESteps.InitVerifyingCache) if (_steps == ESteps.InitVerifyingCache)
@ -188,7 +215,7 @@ namespace YooAsset
/// <summary> /// <summary>
/// 解析并保存远端请求的补丁清单 /// 解析并保存远端请求的补丁清单
/// </summary> /// </summary>
private bool ParseAndSaveRemotePatchManifest(string packageName, string packageCRC, string content) private bool ParseAndSaveRemotePatchManifest(string packageName, string packageVersion, string content)
{ {
try try
{ {
@ -196,7 +223,7 @@ namespace YooAsset
_impl.SetLocalPatchManifest(remotePatchManifest); _impl.SetLocalPatchManifest(remotePatchManifest);
YooLogger.Log("Save remote patch manifest file."); YooLogger.Log("Save remote patch manifest file.");
string fileName = YooAssetSettingsData.GetPatchManifestFileName(packageName, packageCRC); string fileName = YooAssetSettingsData.GetPatchManifestFileName(packageName, packageVersion);
string savePath = PathHelper.MakePersistentLoadPath(fileName); string savePath = PathHelper.MakePersistentLoadPath(fileName);
PatchManifest.Serialize(savePath, remotePatchManifest); PatchManifest.Serialize(savePath, remotePatchManifest);
return true; return true;
@ -212,10 +239,10 @@ namespace YooAsset
/// 加载沙盒内的补丁清单 /// 加载沙盒内的补丁清单
/// 注意:在加载本地补丁清单之前,已经验证过文件的哈希值 /// 注意:在加载本地补丁清单之前,已经验证过文件的哈希值
/// </summary> /// </summary>
private void LoadSandboxPatchManifest(string packageName, string packageCRC) private void LoadSandboxPatchManifest(string packageName, string packageVersion)
{ {
YooLogger.Log("Load sandbox patch manifest file."); YooLogger.Log("Load sandbox patch manifest file.");
string fileName = YooAssetSettingsData.GetPatchManifestFileName(packageName, packageCRC); string fileName = YooAssetSettingsData.GetPatchManifestFileName(packageName, packageVersion);
string filePath = PathHelper.MakePersistentLoadPath(fileName); string filePath = PathHelper.MakePersistentLoadPath(fileName);
string jsonData = File.ReadAllText(filePath); string jsonData = File.ReadAllText(filePath);
var sandboxPatchManifest = PatchManifest.Deserialize(jsonData); var sandboxPatchManifest = PatchManifest.Deserialize(jsonData);
@ -226,12 +253,12 @@ namespace YooAsset
/// 获取沙盒内补丁清单文件的哈希值 /// 获取沙盒内补丁清单文件的哈希值
/// 注意:如果沙盒内补丁清单文件不存在,返回空字符串 /// 注意:如果沙盒内补丁清单文件不存在,返回空字符串
/// </summary> /// </summary>
private string GetSandboxPatchManifestFileHash(string packageName, string packageCRC) private string GetSandboxPatchManifestFileHash(string packageName, string packageVersion)
{ {
string fileName = YooAssetSettingsData.GetPatchManifestFileName(packageName, packageCRC); string fileName = YooAssetSettingsData.GetPatchManifestFileName(packageName, packageVersion);
string filePath = PathHelper.MakePersistentLoadPath(fileName); string filePath = PathHelper.MakePersistentLoadPath(fileName);
if (File.Exists(filePath)) if (File.Exists(filePath))
return HashUtility.FileCRC32(filePath); return HashUtility.FileMD5(filePath);
else else
return string.Empty; return string.Empty;
} }
@ -253,16 +280,16 @@ namespace YooAsset
private readonly HostPlayModeImpl _impl; private readonly HostPlayModeImpl _impl;
private readonly string _packageName; private readonly string _packageName;
private readonly string _packageCRC; private readonly string _packageVersion;
private ESteps _steps = ESteps.None; private ESteps _steps = ESteps.None;
private CacheVerifier _cacheVerifier; private CacheVerifier _cacheVerifier;
private float _verifyTime; private float _verifyTime;
internal HostPlayModeWeaklyUpdateManifestOperation(HostPlayModeImpl impl, string packageName, string packageCRC) internal HostPlayModeWeaklyUpdateManifestOperation(HostPlayModeImpl impl, string packageName, string packageVersion)
{ {
_impl = impl; _impl = impl;
_packageName = packageName; _packageName = packageName;
_packageCRC = packageCRC; _packageVersion = packageVersion;
#if UNITY_WEBGL #if UNITY_WEBGL
_cacheVerifier = new CacheVerifierWithoutThread(); _cacheVerifier = new CacheVerifierWithoutThread();
@ -281,7 +308,7 @@ namespace YooAsset
if (_steps == ESteps.LoadSandboxManifestHash) if (_steps == ESteps.LoadSandboxManifestHash)
{ {
LoadSandboxPatchManifest(_packageName, _packageCRC); LoadSandboxPatchManifest(_packageName, _packageVersion);
_steps = ESteps.InitVerifyingCache; _steps = ESteps.InitVerifyingCache;
} }
@ -321,7 +348,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = $"The package resource {_packageName}_{_packageCRC} content has verify failed file !"; Error = $"The package resource {_packageName}_{_packageVersion} content has verify failed file !";
} }
} }
} }
@ -331,9 +358,9 @@ namespace YooAsset
/// 加载沙盒内的补丁清单 /// 加载沙盒内的补丁清单
/// 注意:在加载本地补丁清单之前,未验证过文件的哈希值 /// 注意:在加载本地补丁清单之前,未验证过文件的哈希值
/// </summary> /// </summary>
private void LoadSandboxPatchManifest(string packageName, string packageCRC) private void LoadSandboxPatchManifest(string packageName, string packageVersion)
{ {
string fileName = YooAssetSettingsData.GetPatchManifestFileName(packageName, packageCRC); string fileName = YooAssetSettingsData.GetPatchManifestFileName(packageName, packageVersion);
string filePath = PathHelper.MakePersistentLoadPath(fileName); string filePath = PathHelper.MakePersistentLoadPath(fileName);
if (File.Exists(filePath)) if (File.Exists(filePath))
{ {

View File

@ -80,17 +80,17 @@ namespace YooAsset
private static int RequestCount = 0; private static int RequestCount = 0;
private readonly HostPlayModeImpl _impl; private readonly HostPlayModeImpl _impl;
private readonly string _packageName; private readonly string _packageName;
private readonly string _packageCRC; private readonly string _packageVersion;
private readonly int _timeout; private readonly int _timeout;
private ESteps _steps = ESteps.None; private ESteps _steps = ESteps.None;
private UnityWebDataRequester _downloader; private UnityWebDataRequester _downloader;
private PatchManifest _remotePatchManifest; private PatchManifest _remotePatchManifest;
internal HostPlayModeUpdatePackageOperation(HostPlayModeImpl impl, string packageName, string packageCRC, int timeout) internal HostPlayModeUpdatePackageOperation(HostPlayModeImpl impl, string packageName, string packageVersion, int timeout)
{ {
_impl = impl; _impl = impl;
_packageName = packageName; _packageName = packageName;
_packageCRC = packageCRC; _packageVersion = packageVersion;
_timeout = timeout; _timeout = timeout;
} }
internal override void Start() internal override void Start()
@ -105,7 +105,7 @@ namespace YooAsset
if (_steps == ESteps.LoadWebManifest) if (_steps == ESteps.LoadWebManifest)
{ {
string fileName = YooAssetSettingsData.GetPatchManifestFileName(_packageName, _packageCRC); string fileName = YooAssetSettingsData.GetPatchManifestFileName(_packageName, _packageVersion);
string webURL = GetPatchManifestRequestURL(fileName); string webURL = GetPatchManifestRequestURL(fileName);
YooLogger.Log($"Beginning to request patch manifest : {webURL}"); YooLogger.Log($"Beginning to request patch manifest : {webURL}");
_downloader = new UnityWebDataRequester(); _downloader = new UnityWebDataRequester();

View File

@ -1,5 +1,6 @@
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine;
namespace YooAsset namespace YooAsset
{ {
@ -9,9 +10,9 @@ namespace YooAsset
public abstract class UpdateStaticVersionOperation : AsyncOperationBase public abstract class UpdateStaticVersionOperation : AsyncOperationBase
{ {
/// <summary> /// <summary>
/// 包裹文件的哈希值 /// 当前最新的包裹版本
/// </summary> /// </summary>
public string PackageCRC { protected set; get; } = string.Empty; public string PackageVersion { protected set; get; }
} }
/// <summary> /// <summary>
@ -80,8 +81,8 @@ namespace YooAsset
if (_steps == ESteps.LoadStaticVersion) if (_steps == ESteps.LoadStaticVersion)
{ {
string versionFileName = YooAssetSettingsData.GetStaticVersionFileName(_packageName); string fileName = YooAssetSettingsData.GetPatchManifestVersionFileName(_packageName);
string webURL = GetStaticVersionRequestURL(versionFileName); string webURL = GetStaticVersionRequestURL(fileName);
YooLogger.Log($"Beginning to request static version : {webURL}"); YooLogger.Log($"Beginning to request static version : {webURL}");
_downloader = new UnityWebDataRequester(); _downloader = new UnityWebDataRequester();
_downloader.SendRequest(webURL, _timeout); _downloader.SendRequest(webURL, _timeout);
@ -102,16 +103,15 @@ namespace YooAsset
} }
else else
{ {
string packageCRC = _downloader.GetText(); PackageVersion = _downloader.GetText();
if(string.IsNullOrEmpty(packageCRC)) if (string.IsNullOrEmpty(PackageVersion))
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = $"URL : {_downloader.URL} Error : static version content is empty."; Error = $"Static package version is empty : {_downloader.URL}";
} }
else else
{ {
PackageCRC = packageCRC;
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Succeed; Status = EOperationStatus.Succeed;
} }

View File

@ -33,9 +33,9 @@ namespace YooAsset
public string PackageName; public string PackageName;
/// <summary> /// <summary>
/// 人类可读的版本信息 /// 资源包裹的版本信息
/// </summary> /// </summary>
public string HumanReadableVersion; public string PackageVersion;
/// <summary> /// <summary>
/// 资源列表(主动收集的资源列表) /// 资源列表(主动收集的资源列表)

View File

@ -21,13 +21,13 @@ namespace YooAsset
} }
/// <summary> /// <summary>
/// 获取人类可读的版本信息 /// 获取包裹的版本信息
/// </summary> /// </summary>
public string GetHumanReadableVersion() public string GetPackageVersion()
{ {
if (_simulatePatchManifest == null) if (_simulatePatchManifest == null)
return string.Empty; return string.Empty;
return _simulatePatchManifest.HumanReadableVersion; return _simulatePatchManifest.PackageVersion;
} }
internal void SetSimulatePatchManifest(PatchManifest patchManifest) internal void SetSimulatePatchManifest(PatchManifest patchManifest)

View File

@ -32,13 +32,13 @@ namespace YooAsset
} }
/// <summary> /// <summary>
/// 获取人类可读的版本信息 /// 获取包裹的版本信息
/// </summary> /// </summary>
public string GetHumanReadableVersion() public string GetPackageVersion()
{ {
if (LocalPatchManifest == null) if (LocalPatchManifest == null)
return string.Empty; return string.Empty;
return LocalPatchManifest.HumanReadableVersion; return LocalPatchManifest.PackageVersion;
} }
/// <summary> /// <summary>
@ -54,9 +54,9 @@ namespace YooAsset
/// <summary> /// <summary>
/// 异步更新补丁清单 /// 异步更新补丁清单
/// </summary> /// </summary>
public UpdateManifestOperation UpdatePatchManifestAsync(string packageName, string packageCRC, int timeout) public UpdateManifestOperation UpdatePatchManifestAsync(string packageName, string packageVersion, int timeout)
{ {
var operation = new HostPlayModeUpdateManifestOperation(this, packageName, packageCRC, timeout); var operation = new HostPlayModeUpdateManifestOperation(this, packageName, packageVersion, timeout);
OperationSystem.StartOperation(operation); OperationSystem.StartOperation(operation);
return operation; return operation;
} }
@ -64,9 +64,9 @@ namespace YooAsset
/// <summary> /// <summary>
/// 异步更新补丁清单(弱联网) /// 异步更新补丁清单(弱联网)
/// </summary> /// </summary>
public UpdateManifestOperation WeaklyUpdatePatchManifestAsync(string packageName, string packageCRC) public UpdateManifestOperation WeaklyUpdatePatchManifestAsync(string packageName, string packageVersion)
{ {
var operation = new HostPlayModeWeaklyUpdateManifestOperation(this, packageName, packageCRC); var operation = new HostPlayModeWeaklyUpdateManifestOperation(this, packageName, packageVersion);
OperationSystem.StartOperation(operation); OperationSystem.StartOperation(operation);
return operation; return operation;
} }
@ -74,9 +74,9 @@ namespace YooAsset
/// <summary> /// <summary>
/// 异步更新资源包裹 /// 异步更新资源包裹
/// </summary> /// </summary>
public UpdatePackageOperation UpdatePackageAsync(string packageName, string packageCRC, int timeout) public UpdatePackageOperation UpdatePackageAsync(string packageName, string packageVersion, int timeout)
{ {
var operation = new HostPlayModeUpdatePackageOperation(this, packageName, packageCRC, timeout); var operation = new HostPlayModeUpdatePackageOperation(this, packageName, packageVersion, timeout);
OperationSystem.StartOperation(operation); OperationSystem.StartOperation(operation);
return operation; return operation;
} }

View File

@ -22,13 +22,13 @@ namespace YooAsset
} }
/// <summary> /// <summary>
/// 获取人类可读的版本信息 /// 获取包裹的版本信息
/// </summary> /// </summary>
public string GetHumanReadableVersion() public string GetPackageVersion()
{ {
if (_appPatchManifest == null) if (_appPatchManifest == null)
return string.Empty; return string.Empty;
return _appPatchManifest.HumanReadableVersion; return _appPatchManifest.PackageVersion;
} }
internal List<VerifyInfo> GetVerifyInfoList() internal List<VerifyInfo> GetVerifyInfoList()

View File

@ -22,9 +22,9 @@ namespace YooAsset
/// <summary> /// <summary>
/// 补丁清单文件版本 /// 补丁清单文件格式版本
/// </summary> /// </summary>
public const string PatchManifestFileVersion = "1.3.0"; public const string PatchManifestFileVersion = "1.3.3";
/// <summary> /// <summary>
/// 构建输出文件夹名称 /// 构建输出文件夹名称
@ -36,11 +36,6 @@ namespace YooAsset
/// </summary> /// </summary>
public const string ReportFileName = "BuildReport"; public const string ReportFileName = "BuildReport";
/// <summary>
/// 静态版本文件
/// </summary>
public const string VersionFileName = "StaticVersion";
/// <summary> /// <summary>
/// Unity着色器资源包名称 /// Unity着色器资源包名称
/// </summary> /// </summary>

View File

@ -35,33 +35,33 @@ namespace YooAsset
/// <summary> /// <summary>
/// 获取构建报告文件名 /// 获取构建报告文件名
/// </summary> /// </summary>
public static string GetReportFileName(string packageName, string packageCRC) public static string GetReportFileName(string packageName, string packageVersion)
{ {
return $"{YooAssetSettings.ReportFileName}_{packageName}_{packageCRC}.json"; return $"{YooAssetSettings.ReportFileName}_{packageName}_{packageVersion}.json";
} }
/// <summary> /// <summary>
/// 获取补丁清单文件完整名称 /// 获取补丁清单文件完整名称
/// </summary> /// </summary>
public static string GetPatchManifestFileName(string packageName, string packageCRC) public static string GetPatchManifestFileName(string packageName, string packageVersion)
{ {
return $"{Setting.PatchManifestFileName}_{packageName}_{packageCRC}.bytes"; return $"{Setting.PatchManifestFileName}_{packageName}_{packageVersion}.bytes";
} }
/// <summary> /// <summary>
/// 获取补丁清单文件临时名称 /// 获取补丁清单哈希文件完整名称
/// </summary> /// </summary>
public static string GetPatchManifestTempFileName(string packageName) public static string GetPatchManifestHashFileName(string packageName, string packageVersion)
{ {
return $"{Setting.PatchManifestFileName}_{packageName}.temp"; return $"{Setting.PatchManifestFileName}_{packageName}_{packageVersion}.hash";
} }
/// <summary> /// <summary>
/// 获取静态版本文件名称 /// 获取补丁清单版本文件完整名称
/// </summary> /// </summary>
public static string GetStaticVersionFileName(string packageName) public static string GetPatchManifestVersionFileName(string packageName)
{ {
return $"{YooAssetSettings.VersionFileName}_{packageName}.bytes"; return $"{Setting.PatchManifestFileName}_{packageName}.version";
} }
/// <summary> /// <summary>

View File

@ -369,12 +369,12 @@ namespace YooAsset
/// <summary> /// <summary>
/// 创建资源包裹下载器,用于下载更新指定资源版本所有的资源包文件 /// 创建资源包裹下载器,用于下载更新指定资源版本所有的资源包文件
/// </summary> /// </summary>
/// <param name="packageCRC">指定更新的资源包裹版本</param> /// <param name="packageVersion">指定更新的包裹版本</param>
/// <param name="timeout">超时时间</param> /// <param name="timeout">超时时间</param>
public static UpdatePackageOperation UpdatePackageAsync(string packageCRC, int timeout = 60) public static UpdatePackageOperation UpdatePackageAsync(string packageVersion, int timeout = 60)
{ {
DebugCheckDefaultPackageValid(); DebugCheckDefaultPackageValid();
return _defaultPackage.UpdatePackageAsync(packageCRC, timeout); return _defaultPackage.UpdatePackageAsync(packageVersion, timeout);
} }
#endregion #endregion