parent
1dab0f2b19
commit
49949ecda5
|
@ -163,7 +163,8 @@ namespace YooAsset
|
||||||
// 5. 从WEB网站获取AssetBundle文件
|
// 5. 从WEB网站获取AssetBundle文件
|
||||||
if (_steps == ESteps.LoadWebFile)
|
if (_steps == ESteps.LoadWebFile)
|
||||||
{
|
{
|
||||||
_webRequest = UnityWebRequestAssetBundle.GetAssetBundle(_fileLoadPath, Hash128.Parse(MainBundleInfo.Bundle.FileHash));
|
var hash = Hash128.Parse(MainBundleInfo.Bundle.FileHash);
|
||||||
|
_webRequest = UnityWebRequestAssetBundle.GetAssetBundle(_fileLoadPath, hash);
|
||||||
_webRequest.SendWebRequest();
|
_webRequest.SendWebRequest();
|
||||||
_steps = ESteps.CheckLoadWebFile;
|
_steps = ESteps.CheckLoadWebFile;
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,24 +185,24 @@ namespace YooAsset
|
||||||
/// 向网络端请求最新的资源版本
|
/// 向网络端请求最新的资源版本
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
||||||
public UpdateStaticVersionOperation UpdateStaticVersionAsync(int timeout = 60)
|
public UpdatePackageVersionOperation UpdatePackageVersionAsync(int timeout = 60)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
if (_playMode == EPlayMode.EditorSimulateMode)
|
if (_playMode == EPlayMode.EditorSimulateMode)
|
||||||
{
|
{
|
||||||
var operation = new EditorPlayModeUpdateStaticVersionOperation();
|
var operation = new EditorPlayModeUpdatePackageVersionOperation();
|
||||||
OperationSystem.StartOperation(operation);
|
OperationSystem.StartOperation(operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
else if (_playMode == EPlayMode.OfflinePlayMode)
|
else if (_playMode == EPlayMode.OfflinePlayMode)
|
||||||
{
|
{
|
||||||
var operation = new OfflinePlayModeUpdateStaticVersionOperation();
|
var operation = new OfflinePlayModeUpdatePackageVersionOperation();
|
||||||
OperationSystem.StartOperation(operation);
|
OperationSystem.StartOperation(operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
else if (_playMode == EPlayMode.HostPlayMode)
|
else if (_playMode == EPlayMode.HostPlayMode)
|
||||||
{
|
{
|
||||||
return _hostPlayModeImpl.UpdateStaticVersionAsync(PackageName, timeout);
|
return _hostPlayModeImpl.UpdatePackageVersionAsync(PackageName, timeout);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -215,25 +215,25 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="packageVersion">更新的包裹版本</param>
|
/// <param name="packageVersion">更新的包裹版本</param>
|
||||||
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
||||||
public UpdateManifestOperation UpdateManifestAsync(string packageVersion, int timeout = 60)
|
public UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, int timeout = 60)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
DebugCheckUpdateManifest();
|
DebugCheckUpdateManifest();
|
||||||
if (_playMode == EPlayMode.EditorSimulateMode)
|
if (_playMode == EPlayMode.EditorSimulateMode)
|
||||||
{
|
{
|
||||||
var operation = new EditorPlayModeUpdateManifestOperation();
|
var operation = new EditorPlayModeUpdatePackageManifestOperation();
|
||||||
OperationSystem.StartOperation(operation);
|
OperationSystem.StartOperation(operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
else if (_playMode == EPlayMode.OfflinePlayMode)
|
else if (_playMode == EPlayMode.OfflinePlayMode)
|
||||||
{
|
{
|
||||||
var operation = new OfflinePlayModeUpdateManifestOperation();
|
var operation = new OfflinePlayModeUpdatePackageManifestOperation();
|
||||||
OperationSystem.StartOperation(operation);
|
OperationSystem.StartOperation(operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
else if (_playMode == EPlayMode.HostPlayMode)
|
else if (_playMode == EPlayMode.HostPlayMode)
|
||||||
{
|
{
|
||||||
return _hostPlayModeImpl.UpdatePatchManifestAsync(PackageName, packageVersion, timeout);
|
return _hostPlayModeImpl.UpdatePackageManifestAsync(PackageName, packageVersion, timeout);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -270,7 +270,18 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取包裹的版本信息
|
/// 清理本地包裹未使用的缓存文件
|
||||||
|
/// </summary>
|
||||||
|
public ClearPackageUnusedCacheFilesOperation ClearPackageUnusedCacheFilesAsync()
|
||||||
|
{
|
||||||
|
DebugCheckInitialize();
|
||||||
|
var operation = new ClearPackageUnusedCacheFilesOperation(this);
|
||||||
|
OperationSystem.StartOperation(operation);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取本地包裹的版本信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string GetPackageVersion()
|
public string GetPackageVersion()
|
||||||
{
|
{
|
||||||
|
@ -899,24 +910,24 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="packageVersion">指定更新的包裹版本</param>
|
/// <param name="packageVersion">指定更新的包裹版本</param>
|
||||||
/// <param name="timeout">超时时间</param>
|
/// <param name="timeout">超时时间</param>
|
||||||
public UpdatePackageOperation UpdatePackageAsync(string packageVersion, int timeout = 60)
|
public DownloadPackageOperation DownloadPackageAsync(string packageVersion, int timeout = 60)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
if (_playMode == EPlayMode.EditorSimulateMode)
|
if (_playMode == EPlayMode.EditorSimulateMode)
|
||||||
{
|
{
|
||||||
var operation = new EditorPlayModeUpdatePackageOperation();
|
var operation = new EditorPlayModeDownloadPackageOperation();
|
||||||
OperationSystem.StartOperation(operation);
|
OperationSystem.StartOperation(operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
else if (_playMode == EPlayMode.OfflinePlayMode)
|
else if (_playMode == EPlayMode.OfflinePlayMode)
|
||||||
{
|
{
|
||||||
var operation = new OfflinePlayModeUpdatePackageOperation();
|
var operation = new OfflinePlayModeDownloadPackageOperation();
|
||||||
OperationSystem.StartOperation(operation);
|
OperationSystem.StartOperation(operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
else if (_playMode == EPlayMode.HostPlayMode)
|
else if (_playMode == EPlayMode.HostPlayMode)
|
||||||
{
|
{
|
||||||
return _hostPlayModeImpl.UpdatePackageAsync(PackageName, packageVersion, timeout);
|
return _hostPlayModeImpl.DownloadPackageAsync(PackageName, packageVersion, timeout);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
|
@ -30,8 +29,8 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static bool IsCached(PatchBundle patchBundle)
|
public static bool IsCached(PatchBundle patchBundle)
|
||||||
{
|
{
|
||||||
string fileHash = patchBundle.FileHash;
|
string cacheKey = patchBundle.CacheKey;
|
||||||
if (_cachedDic.ContainsKey(fileHash))
|
if (_cachedDic.ContainsKey(cacheKey))
|
||||||
{
|
{
|
||||||
string filePath = patchBundle.CachedFilePath;
|
string filePath = patchBundle.CachedFilePath;
|
||||||
if (File.Exists(filePath))
|
if (File.Exists(filePath))
|
||||||
|
@ -40,7 +39,7 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_cachedDic.Remove(fileHash);
|
_cachedDic.Remove(cacheKey);
|
||||||
YooLogger.Error($"Cache file is missing : {filePath}");
|
YooLogger.Error($"Cache file is missing : {filePath}");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -56,12 +55,12 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void CacheBundle(PatchBundle patchBundle)
|
public static void CacheBundle(PatchBundle patchBundle)
|
||||||
{
|
{
|
||||||
string fileHash = patchBundle.FileHash;
|
string cacheKey = patchBundle.CacheKey;
|
||||||
if (_cachedDic.ContainsKey(fileHash) == false)
|
if (_cachedDic.ContainsKey(cacheKey) == false)
|
||||||
{
|
{
|
||||||
string filePath = patchBundle.CachedFilePath;
|
string filePath = patchBundle.CachedFilePath;
|
||||||
YooLogger.Log($"Cache verify file : {filePath}");
|
YooLogger.Log($"Cache verify file : {filePath}");
|
||||||
_cachedDic.Add(fileHash, patchBundle);
|
_cachedDic.Add(cacheKey, patchBundle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,9 @@ using System.IO;
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清理未使用的缓存资源操作类
|
/// 清理本地包裹未使用的缓存文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class ClearUnusedCacheFilesOperation : AsyncOperationBase
|
public sealed class ClearPackageUnusedCacheFilesOperation : AsyncOperationBase
|
||||||
{
|
{
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
|
@ -17,14 +17,14 @@ namespace YooAsset
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly List<AssetsPackage> _packages;
|
private readonly AssetsPackage _package;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
private List<string> _unusedCacheFilePaths;
|
private List<string> _unusedCacheFilePaths;
|
||||||
private int _unusedFileTotalCount = 0;
|
private int _unusedFileTotalCount = 0;
|
||||||
|
|
||||||
internal ClearUnusedCacheFilesOperation(List<AssetsPackage> packages)
|
internal ClearPackageUnusedCacheFilesOperation(AssetsPackage package)
|
||||||
{
|
{
|
||||||
_packages = packages;
|
_package = package;
|
||||||
}
|
}
|
||||||
internal override void Start()
|
internal override void Start()
|
||||||
{
|
{
|
||||||
|
@ -84,27 +84,19 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private List<string> GetUnusedCacheFilePaths()
|
private List<string> GetUnusedCacheFilePaths()
|
||||||
{
|
{
|
||||||
string cacheFolderPath = PersistentHelper.GetCacheFolderPath();
|
string cacheFolderPath = PersistentHelper.GetCacheFolderPath(_package.PackageName);
|
||||||
if (Directory.Exists(cacheFolderPath) == false)
|
if (Directory.Exists(cacheFolderPath) == false)
|
||||||
return new List<string>();
|
return new List<string>();
|
||||||
|
|
||||||
// 获取所有缓存文件
|
|
||||||
DirectoryInfo directoryInfo = new DirectoryInfo(cacheFolderPath);
|
DirectoryInfo directoryInfo = new DirectoryInfo(cacheFolderPath);
|
||||||
FileInfo[] fileInfos = directoryInfo.GetFiles();
|
FileInfo[] fileInfos = directoryInfo.GetFiles();
|
||||||
List<string> result = new List<string>(fileInfos.Length);
|
List<string> result = new List<string>(fileInfos.Length);
|
||||||
foreach (FileInfo fileInfo in fileInfos)
|
foreach (FileInfo fileInfo in fileInfos)
|
||||||
{
|
{
|
||||||
bool used = false;
|
if (_package.IsIncludeBundleFile(fileInfo.Name) == false)
|
||||||
foreach (var package in _packages)
|
|
||||||
{
|
{
|
||||||
if (package.IsIncludeBundleFile(fileInfo.Name))
|
|
||||||
{
|
|
||||||
used = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (used == false)
|
|
||||||
result.Add(fileInfo.FullName);
|
result.Add(fileInfo.FullName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
|
@ -5,7 +5,7 @@ using System.IO;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
public abstract class UpdatePackageOperation : AsyncOperationBase
|
public abstract class DownloadPackageOperation : AsyncOperationBase
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建包裹下载器
|
/// 创建包裹下载器
|
||||||
|
@ -19,7 +19,7 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 编辑器下模拟运行的更新资源包裹操作
|
/// 编辑器下模拟运行的更新资源包裹操作
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class EditorPlayModeUpdatePackageOperation : UpdatePackageOperation
|
internal sealed class EditorPlayModeDownloadPackageOperation : DownloadPackageOperation
|
||||||
{
|
{
|
||||||
internal override void Start()
|
internal override void Start()
|
||||||
{
|
{
|
||||||
|
@ -43,7 +43,7 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 离线模式的更新资源包裹操作
|
/// 离线模式的更新资源包裹操作
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class OfflinePlayModeUpdatePackageOperation : UpdatePackageOperation
|
internal sealed class OfflinePlayModeDownloadPackageOperation : DownloadPackageOperation
|
||||||
{
|
{
|
||||||
internal override void Start()
|
internal override void Start()
|
||||||
{
|
{
|
||||||
|
@ -67,7 +67,7 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 联机模式的更新资源包裹操作
|
/// 联机模式的更新资源包裹操作
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class HostPlayModeUpdatePackageOperation : UpdatePackageOperation
|
internal sealed class HostPlayModeDownloadPackageOperation : DownloadPackageOperation
|
||||||
{
|
{
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
|
@ -86,7 +86,7 @@ namespace YooAsset
|
||||||
private UnityWebDataRequester _downloader;
|
private UnityWebDataRequester _downloader;
|
||||||
private PatchManifest _remotePatchManifest;
|
private PatchManifest _remotePatchManifest;
|
||||||
|
|
||||||
internal HostPlayModeUpdatePackageOperation(HostPlayModeImpl impl, string packageName, string packageVersion, int timeout)
|
internal HostPlayModeDownloadPackageOperation(HostPlayModeImpl impl, string packageName, string packageVersion, int timeout)
|
||||||
{
|
{
|
||||||
_impl = impl;
|
_impl = impl;
|
||||||
_packageName = packageName;
|
_packageName = packageName;
|
||||||
|
@ -160,7 +160,7 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
YooLogger.Error($"{nameof(UpdatePackageOperation)} status is failed !");
|
YooLogger.Error($"{nameof(DownloadPackageOperation)} status is failed !");
|
||||||
var operation = new PackageDownloaderOperation(null, downloadingMaxNumber, failedTryAgain, timeout);
|
var operation = new PackageDownloaderOperation(null, downloadingMaxNumber, failedTryAgain, timeout);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
|
@ -6,9 +6,9 @@ using System.IO;
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 更新清单操作
|
/// 向远端请求并更新补丁清单
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class UpdateManifestOperation : AsyncOperationBase
|
public abstract class UpdatePackageManifestOperation : AsyncOperationBase
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否发现了新的补丁清单
|
/// 是否发现了新的补丁清单
|
||||||
|
@ -19,7 +19,7 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 编辑器下模拟运行的更新清单操作
|
/// 编辑器下模拟运行的更新清单操作
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class EditorPlayModeUpdateManifestOperation : UpdateManifestOperation
|
internal sealed class EditorPlayModeUpdatePackageManifestOperation : UpdatePackageManifestOperation
|
||||||
{
|
{
|
||||||
internal override void Start()
|
internal override void Start()
|
||||||
{
|
{
|
||||||
|
@ -33,7 +33,7 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 离线模式的更新清单操作
|
/// 离线模式的更新清单操作
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class OfflinePlayModeUpdateManifestOperation : UpdateManifestOperation
|
internal sealed class OfflinePlayModeUpdatePackageManifestOperation : UpdatePackageManifestOperation
|
||||||
{
|
{
|
||||||
internal override void Start()
|
internal override void Start()
|
||||||
{
|
{
|
||||||
|
@ -48,7 +48,7 @@ namespace YooAsset
|
||||||
/// 联机模式的更新清单操作
|
/// 联机模式的更新清单操作
|
||||||
/// 注意:优先比对沙盒清单哈希值,如果有变化就更新远端清单文件,并保存到本地。
|
/// 注意:优先比对沙盒清单哈希值,如果有变化就更新远端清单文件,并保存到本地。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class HostPlayModeUpdateManifestOperation : UpdateManifestOperation
|
internal sealed class HostPlayModeUpdatePackageManifestOperation : UpdatePackageManifestOperation
|
||||||
{
|
{
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
|
@ -77,7 +77,7 @@ namespace YooAsset
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
private float _verifyTime;
|
private float _verifyTime;
|
||||||
|
|
||||||
internal HostPlayModeUpdateManifestOperation(HostPlayModeImpl impl, string packageName, string packageVersion, int timeout)
|
internal HostPlayModeUpdatePackageManifestOperation(HostPlayModeImpl impl, string packageName, string packageVersion, int timeout)
|
||||||
{
|
{
|
||||||
_impl = impl;
|
_impl = impl;
|
||||||
_packageName = packageName;
|
_packageName = packageName;
|
|
@ -5,9 +5,9 @@ using UnityEngine;
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取包裹的最新版本
|
/// 请求远端包裹的最新版本
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class UpdateStaticVersionOperation : AsyncOperationBase
|
public abstract class UpdatePackageVersionOperation : AsyncOperationBase
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 当前最新的包裹版本
|
/// 当前最新的包裹版本
|
||||||
|
@ -16,9 +16,9 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 编辑器下模拟运行的获取包裹的最新版本操作
|
/// 编辑器下模拟模式的请求远端包裹的最新版本
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class EditorPlayModeUpdateStaticVersionOperation : UpdateStaticVersionOperation
|
internal sealed class EditorPlayModeUpdatePackageVersionOperation : UpdatePackageVersionOperation
|
||||||
{
|
{
|
||||||
internal override void Start()
|
internal override void Start()
|
||||||
{
|
{
|
||||||
|
@ -30,9 +30,9 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 离线模式的获取包裹的最新版本操作
|
/// 离线模式的请求远端包裹的最新版本
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class OfflinePlayModeUpdateStaticVersionOperation : UpdateStaticVersionOperation
|
internal sealed class OfflinePlayModeUpdatePackageVersionOperation : UpdatePackageVersionOperation
|
||||||
{
|
{
|
||||||
internal override void Start()
|
internal override void Start()
|
||||||
{
|
{
|
||||||
|
@ -44,9 +44,9 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 联机模式的获取包裹的最新版本操作
|
/// 联机模式的请求远端包裹的最新版本
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class HostPlayModeUpdateStaticVersionOperation : UpdateStaticVersionOperation
|
internal sealed class HostPlayModeUpdatePackageVersionOperation : UpdatePackageVersionOperation
|
||||||
{
|
{
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
|
@ -63,7 +63,7 @@ namespace YooAsset
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
private UnityWebDataRequester _downloader;
|
private UnityWebDataRequester _downloader;
|
||||||
|
|
||||||
internal HostPlayModeUpdateStaticVersionOperation(HostPlayModeImpl impl, string packageName, int timeout)
|
internal HostPlayModeUpdatePackageVersionOperation(HostPlayModeImpl impl, string packageName, int timeout)
|
||||||
{
|
{
|
||||||
_impl = impl;
|
_impl = impl;
|
||||||
_packageName = packageName;
|
_packageName = packageName;
|
|
@ -41,10 +41,11 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string[] Tags;
|
public string[] Tags;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件名称
|
/// 所属的包裹名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string FileName { private set; get; }
|
private string _packageName;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 缓存文件路径
|
/// 缓存文件路径
|
||||||
|
@ -57,7 +58,7 @@ namespace YooAsset
|
||||||
if (string.IsNullOrEmpty(_cachedFilePath) == false)
|
if (string.IsNullOrEmpty(_cachedFilePath) == false)
|
||||||
return _cachedFilePath;
|
return _cachedFilePath;
|
||||||
|
|
||||||
string cacheRoot = PersistentHelper.GetCacheFolderPath();
|
string cacheRoot = PersistentHelper.GetCacheFolderPath(_packageName);
|
||||||
_cachedFilePath = $"{cacheRoot}/{FileName}";
|
_cachedFilePath = $"{cacheRoot}/{FileName}";
|
||||||
return _cachedFilePath;
|
return _cachedFilePath;
|
||||||
}
|
}
|
||||||
|
@ -79,6 +80,34 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文件名称
|
||||||
|
/// </summary>
|
||||||
|
private string _fileName;
|
||||||
|
public string FileName
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(_fileName))
|
||||||
|
throw new Exception("Should never get here !");
|
||||||
|
return _fileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 缓存查询Key
|
||||||
|
/// </summary>
|
||||||
|
private string _cacheKey;
|
||||||
|
public string CacheKey
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(_cacheKey))
|
||||||
|
throw new Exception("Should never get here !");
|
||||||
|
return _cacheKey;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public PatchBundle(string bundleName, string fileHash, string fileCRC, long fileSize, bool isRawFile, byte loadMethod, string[] tags)
|
public PatchBundle(string bundleName, string fileHash, string fileCRC, long fileSize, bool isRawFile, byte loadMethod, string[] tags)
|
||||||
{
|
{
|
||||||
|
@ -92,11 +121,13 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 解析文件名称
|
/// 解析资源包
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void ParseFileName(int nameStype)
|
public void ParseBundle(string packageName, int nameStype)
|
||||||
{
|
{
|
||||||
FileName = PatchManifest.CreateBundleFileName(nameStype, BundleName, FileHash);
|
_packageName = packageName;
|
||||||
|
_cacheKey = $"{packageName}-{FileHash}";
|
||||||
|
_fileName = PatchManifest.CreateBundleFileName(nameStype, BundleName, FileHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -290,7 +290,7 @@ namespace YooAsset
|
||||||
// BundleList
|
// BundleList
|
||||||
foreach (var patchBundle in patchManifest.BundleList)
|
foreach (var patchBundle in patchManifest.BundleList)
|
||||||
{
|
{
|
||||||
patchBundle.ParseFileName(patchManifest.OutputNameStyle);
|
patchBundle.ParseBundle(patchManifest.PackageName, patchManifest.OutputNameStyle);
|
||||||
patchManifest.BundleDic.Add(patchBundle.BundleName, patchBundle);
|
patchManifest.BundleDic.Add(patchBundle.BundleName, patchBundle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,9 +44,9 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步更新资源版本号
|
/// 异步更新资源版本号
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public UpdateStaticVersionOperation UpdateStaticVersionAsync(string packageName, int timeout)
|
public UpdatePackageVersionOperation UpdatePackageVersionAsync(string packageName, int timeout)
|
||||||
{
|
{
|
||||||
var operation = new HostPlayModeUpdateStaticVersionOperation(this, packageName, timeout);
|
var operation = new HostPlayModeUpdatePackageVersionOperation(this, packageName, timeout);
|
||||||
OperationSystem.StartOperation(operation);
|
OperationSystem.StartOperation(operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
@ -54,9 +54,9 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步更新补丁清单
|
/// 异步更新补丁清单
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public UpdateManifestOperation UpdatePatchManifestAsync(string packageName, string packageVersion, int timeout)
|
public UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageName, string packageVersion, int timeout)
|
||||||
{
|
{
|
||||||
var operation = new HostPlayModeUpdateManifestOperation(this, packageName, packageVersion, timeout);
|
var operation = new HostPlayModeUpdatePackageManifestOperation(this, packageName, packageVersion, timeout);
|
||||||
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 packageVersion, int timeout)
|
public DownloadPackageOperation DownloadPackageAsync(string packageName, string packageVersion, int timeout)
|
||||||
{
|
{
|
||||||
var operation = new HostPlayModeUpdatePackageOperation(this, packageName, packageVersion, timeout);
|
var operation = new HostPlayModeDownloadPackageOperation(this, packageName, packageVersion, timeout);
|
||||||
OperationSystem.StartOperation(operation);
|
OperationSystem.StartOperation(operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,17 +97,18 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void DeleteCacheFolder()
|
public static void DeleteCacheFolder()
|
||||||
{
|
{
|
||||||
string directoryPath = GetCacheFolderPath();
|
string root = PathHelper.MakePersistentLoadPath(CacheFolderName);
|
||||||
if (Directory.Exists(directoryPath))
|
if (Directory.Exists(root))
|
||||||
Directory.Delete(directoryPath, true);
|
Directory.Delete(root, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取缓存文件夹路径
|
/// 获取缓存文件夹路径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string GetCacheFolderPath()
|
public static string GetCacheFolderPath(string packageName)
|
||||||
{
|
{
|
||||||
return PathHelper.MakePersistentLoadPath(CacheFolderName);
|
string root = PathHelper.MakePersistentLoadPath(CacheFolderName);
|
||||||
|
return $"{root}/{packageName}";
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 沙盒内清单相关
|
#region 沙盒内清单相关
|
||||||
|
|
|
@ -193,16 +193,6 @@ namespace YooAsset
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 沙盒相关
|
#region 沙盒相关
|
||||||
/// <summary>
|
|
||||||
/// 清理未使用的缓存文件
|
|
||||||
/// </summary>
|
|
||||||
public static ClearUnusedCacheFilesOperation ClearUnusedCacheFiles()
|
|
||||||
{
|
|
||||||
ClearUnusedCacheFilesOperation operation = new ClearUnusedCacheFilesOperation(_packages);
|
|
||||||
OperationSystem.StartOperation(operation);
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取内置文件夹名称
|
/// 获取内置文件夹名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -367,14 +367,14 @@ namespace YooAsset
|
||||||
|
|
||||||
#region 包裹更新
|
#region 包裹更新
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建资源包裹下载器,用于下载更新指定资源版本所有的资源包文件
|
/// 资源包裹更新,用于下载更新指定资源版本所有的资源包文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="packageVersion">指定更新的包裹版本</param>
|
/// <param name="packageVersion">指定更新的包裹版本</param>
|
||||||
/// <param name="timeout">超时时间</param>
|
/// <param name="timeout">超时时间</param>
|
||||||
public static UpdatePackageOperation UpdatePackageAsync(string packageVersion, int timeout = 60)
|
public static DownloadPackageOperation DownloadPackageAsync(string packageVersion, int timeout = 60)
|
||||||
{
|
{
|
||||||
DebugCheckDefaultPackageValid();
|
DebugCheckDefaultPackageValid();
|
||||||
return _defaultPackage.UpdatePackageAsync(packageVersion, timeout);
|
return _defaultPackage.DownloadPackageAsync(packageVersion, timeout);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue