update runtime code
parent
fc55b1be82
commit
2ace30acd8
|
@ -13,10 +13,8 @@ namespace YooAsset
|
||||||
private EOperationStatus _initializeStatus = EOperationStatus.None;
|
private EOperationStatus _initializeStatus = EOperationStatus.None;
|
||||||
private EPlayMode _playMode;
|
private EPlayMode _playMode;
|
||||||
private IBundleServices _bundleServices;
|
private IBundleServices _bundleServices;
|
||||||
|
private IPlayModeServices _playModeServices;
|
||||||
private AssetSystemImpl _assetSystemImpl;
|
private AssetSystemImpl _assetSystemImpl;
|
||||||
private EditorSimulateModeImpl _editorSimulateModeImpl;
|
|
||||||
private OfflinePlayModeImpl _offlinePlayModeImpl;
|
|
||||||
private HostPlayModeImpl _hostPlayModeImpl;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 包裹名
|
/// 包裹名
|
||||||
|
@ -59,11 +57,8 @@ namespace YooAsset
|
||||||
_isInitialize = false;
|
_isInitialize = false;
|
||||||
_initializeError = string.Empty;
|
_initializeError = string.Empty;
|
||||||
_initializeStatus = EOperationStatus.None;
|
_initializeStatus = EOperationStatus.None;
|
||||||
|
|
||||||
_bundleServices = null;
|
_bundleServices = null;
|
||||||
_editorSimulateModeImpl = null;
|
_playModeServices = null;
|
||||||
_offlinePlayModeImpl = null;
|
|
||||||
_hostPlayModeImpl = null;
|
|
||||||
|
|
||||||
if (_assetSystemImpl != null)
|
if (_assetSystemImpl != null)
|
||||||
{
|
{
|
||||||
|
@ -89,36 +84,39 @@ namespace YooAsset
|
||||||
_assetSystemImpl = new AssetSystemImpl();
|
_assetSystemImpl = new AssetSystemImpl();
|
||||||
if (_playMode == EPlayMode.EditorSimulateMode)
|
if (_playMode == EPlayMode.EditorSimulateMode)
|
||||||
{
|
{
|
||||||
_editorSimulateModeImpl = new EditorSimulateModeImpl();
|
var editorSimulateModeImpl = new EditorSimulateModeImpl();
|
||||||
_bundleServices = _editorSimulateModeImpl;
|
_bundleServices = editorSimulateModeImpl;
|
||||||
|
_playModeServices = editorSimulateModeImpl;
|
||||||
_assetSystemImpl.Initialize(true, parameters.AssetLoadingMaxNumber, parameters.DecryptionServices, _bundleServices);
|
_assetSystemImpl.Initialize(true, parameters.AssetLoadingMaxNumber, parameters.DecryptionServices, _bundleServices);
|
||||||
|
|
||||||
var initializeParameters = parameters as EditorSimulateModeParameters;
|
var initializeParameters = parameters as EditorSimulateModeParameters;
|
||||||
initializeOperation = _editorSimulateModeImpl.InitializeAsync(
|
initializeOperation = editorSimulateModeImpl.InitializeAsync(PackageName, initializeParameters.LocationToLower, initializeParameters.SimulatePatchManifestPath);
|
||||||
initializeParameters.LocationToLower,
|
|
||||||
initializeParameters.SimulatePatchManifestPath);
|
|
||||||
}
|
}
|
||||||
else if (_playMode == EPlayMode.OfflinePlayMode)
|
else if (_playMode == EPlayMode.OfflinePlayMode)
|
||||||
{
|
{
|
||||||
_offlinePlayModeImpl = new OfflinePlayModeImpl();
|
var offlinePlayModeImpl = new OfflinePlayModeImpl();
|
||||||
_bundleServices = _offlinePlayModeImpl;
|
_bundleServices = offlinePlayModeImpl;
|
||||||
|
_playModeServices = offlinePlayModeImpl;
|
||||||
_assetSystemImpl.Initialize(false, parameters.AssetLoadingMaxNumber, parameters.DecryptionServices, _bundleServices);
|
_assetSystemImpl.Initialize(false, parameters.AssetLoadingMaxNumber, parameters.DecryptionServices, _bundleServices);
|
||||||
|
|
||||||
var initializeParameters = parameters as OfflinePlayModeParameters;
|
var initializeParameters = parameters as OfflinePlayModeParameters;
|
||||||
initializeOperation = _offlinePlayModeImpl.InitializeAsync(
|
initializeOperation = offlinePlayModeImpl.InitializeAsync(PackageName, initializeParameters.LocationToLower);
|
||||||
initializeParameters.LocationToLower,
|
|
||||||
PackageName);
|
|
||||||
}
|
}
|
||||||
else if (_playMode == EPlayMode.HostPlayMode)
|
else if (_playMode == EPlayMode.HostPlayMode)
|
||||||
{
|
{
|
||||||
_hostPlayModeImpl = new HostPlayModeImpl();
|
var hostPlayModeImpl = new HostPlayModeImpl();
|
||||||
_bundleServices = _hostPlayModeImpl;
|
_bundleServices = hostPlayModeImpl;
|
||||||
|
_playModeServices = hostPlayModeImpl;
|
||||||
_assetSystemImpl.Initialize(false, parameters.AssetLoadingMaxNumber, parameters.DecryptionServices, _bundleServices);
|
_assetSystemImpl.Initialize(false, parameters.AssetLoadingMaxNumber, parameters.DecryptionServices, _bundleServices);
|
||||||
|
|
||||||
var initializeParameters = parameters as HostPlayModeParameters;
|
var initializeParameters = parameters as HostPlayModeParameters;
|
||||||
initializeOperation = _hostPlayModeImpl.InitializeAsync(
|
initializeOperation = hostPlayModeImpl.InitializeAsync(
|
||||||
|
PackageName,
|
||||||
initializeParameters.LocationToLower,
|
initializeParameters.LocationToLower,
|
||||||
initializeParameters.DefaultHostServer,
|
initializeParameters.DefaultHostServer,
|
||||||
initializeParameters.FallbackHostServer,
|
initializeParameters.FallbackHostServer,
|
||||||
initializeParameters.QueryServices,
|
initializeParameters.QueryServices
|
||||||
PackageName);
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -138,10 +136,8 @@ namespace YooAsset
|
||||||
_initializeStatus = EOperationStatus.None;
|
_initializeStatus = EOperationStatus.None;
|
||||||
_initializeError = string.Empty;
|
_initializeError = string.Empty;
|
||||||
_bundleServices = null;
|
_bundleServices = null;
|
||||||
|
_playModeServices = null;
|
||||||
_assetSystemImpl = null;
|
_assetSystemImpl = null;
|
||||||
_editorSimulateModeImpl = null;
|
|
||||||
_offlinePlayModeImpl = null;
|
|
||||||
_hostPlayModeImpl = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void CheckInitializeParameters(InitializeParameters parameters)
|
private void CheckInitializeParameters(InitializeParameters parameters)
|
||||||
|
@ -201,62 +197,25 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 向网络端请求最新的资源版本
|
/// 向网络端请求最新的资源版本
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
|
||||||
/// <param name="appendTimeTicks">在URL末尾添加时间戳</param>
|
/// <param name="appendTimeTicks">在URL末尾添加时间戳</param>
|
||||||
public UpdatePackageVersionOperation UpdatePackageVersionAsync(int timeout = 60, bool appendTimeTicks = true)
|
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
||||||
|
public UpdatePackageVersionOperation UpdatePackageVersionAsync(bool appendTimeTicks = true, int timeout = 60)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
if (_playMode == EPlayMode.EditorSimulateMode)
|
return _playModeServices.UpdatePackageVersionAsync(appendTimeTicks, timeout);
|
||||||
{
|
|
||||||
var operation = new EditorPlayModeUpdatePackageVersionOperation();
|
|
||||||
OperationSystem.StartOperation(operation);
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
else if (_playMode == EPlayMode.OfflinePlayMode)
|
|
||||||
{
|
|
||||||
var operation = new OfflinePlayModeUpdatePackageVersionOperation();
|
|
||||||
OperationSystem.StartOperation(operation);
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
else if (_playMode == EPlayMode.HostPlayMode)
|
|
||||||
{
|
|
||||||
return _hostPlayModeImpl.UpdatePackageVersionAsync(PackageName, timeout, appendTimeTicks);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 向网络端请求并更新补丁清单
|
/// 向网络端请求并更新补丁清单
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="packageVersion">更新的包裹版本</param>
|
/// <param name="packageVersion">更新的包裹版本</param>
|
||||||
|
/// <param name="autoActiveManifest">自动激活清单</param>
|
||||||
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
||||||
public UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, int timeout = 60)
|
public UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, bool autoSaveManifest = true, bool autoActiveManifest = true, int timeout = 60)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
DebugCheckUpdateManifest();
|
DebugCheckUpdateManifest();
|
||||||
if (_playMode == EPlayMode.EditorSimulateMode)
|
return _playModeServices.UpdatePackageManifestAsync(packageVersion, autoSaveManifest, autoActiveManifest, timeout);
|
||||||
{
|
|
||||||
var operation = new EditorPlayModeUpdatePackageManifestOperation();
|
|
||||||
OperationSystem.StartOperation(operation);
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
else if (_playMode == EPlayMode.OfflinePlayMode)
|
|
||||||
{
|
|
||||||
var operation = new OfflinePlayModeUpdatePackageManifestOperation();
|
|
||||||
OperationSystem.StartOperation(operation);
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
else if (_playMode == EPlayMode.HostPlayMode)
|
|
||||||
{
|
|
||||||
return _hostPlayModeImpl.UpdatePackageManifestAsync(PackageName, packageVersion, timeout);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -265,26 +224,7 @@ namespace YooAsset
|
||||||
public CheckPackageContentsOperation CheckPackageContentsAsync()
|
public CheckPackageContentsOperation CheckPackageContentsAsync()
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
if (_playMode == EPlayMode.EditorSimulateMode)
|
return _playModeServices.CheckPackageContentsAsync();
|
||||||
{
|
|
||||||
var operation = new EditorSimulateModeCheckPackageContentsOperation();
|
|
||||||
OperationSystem.StartOperation(operation);
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
else if (_playMode == EPlayMode.OfflinePlayMode)
|
|
||||||
{
|
|
||||||
var operation = new OfflinePlayModeCheckPackageContentsOperation();
|
|
||||||
OperationSystem.StartOperation(operation);
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
else if (_playMode == EPlayMode.HostPlayMode)
|
|
||||||
{
|
|
||||||
return _hostPlayModeImpl.CheckPackageContentsAsync(PackageName);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -304,22 +244,7 @@ namespace YooAsset
|
||||||
public string GetPackageVersion()
|
public string GetPackageVersion()
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
if (_playMode == EPlayMode.EditorSimulateMode)
|
return _playModeServices.GetPackageVersion();
|
||||||
{
|
|
||||||
return _editorSimulateModeImpl.GetPackageVersion();
|
|
||||||
}
|
|
||||||
else if (_playMode == EPlayMode.OfflinePlayMode)
|
|
||||||
{
|
|
||||||
return _offlinePlayModeImpl.GetPackageVersion();
|
|
||||||
}
|
|
||||||
else if (_playMode == EPlayMode.HostPlayMode)
|
|
||||||
{
|
|
||||||
return _hostPlayModeImpl.GetPackageVersion();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -710,7 +635,7 @@ namespace YooAsset
|
||||||
public PatchDownloaderOperation CreatePatchDownloader(string tag, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
public PatchDownloaderOperation CreatePatchDownloader(string tag, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
return CreatePatchDownloader(new string[] { tag }, downloadingMaxNumber, failedTryAgain, timeout);
|
return _playModeServices.CreatePatchDownloaderByTags(new string[] { tag }, downloadingMaxNumber, failedTryAgain, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -723,20 +648,7 @@ namespace YooAsset
|
||||||
public PatchDownloaderOperation CreatePatchDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
public PatchDownloaderOperation CreatePatchDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
if (_playMode == EPlayMode.EditorSimulateMode || _playMode == EPlayMode.OfflinePlayMode)
|
return _playModeServices.CreatePatchDownloaderByTags(tags, downloadingMaxNumber, failedTryAgain, timeout);
|
||||||
{
|
|
||||||
List<BundleInfo> downloadList = new List<BundleInfo>();
|
|
||||||
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
else if (_playMode == EPlayMode.HostPlayMode)
|
|
||||||
{
|
|
||||||
return _hostPlayModeImpl.CreatePatchDownloaderByTags(tags, downloadingMaxNumber, failedTryAgain, timeout);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -748,20 +660,7 @@ namespace YooAsset
|
||||||
public PatchDownloaderOperation CreatePatchDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
public PatchDownloaderOperation CreatePatchDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
if (_playMode == EPlayMode.EditorSimulateMode || _playMode == EPlayMode.OfflinePlayMode)
|
return _playModeServices.CreatePatchDownloaderByAll(downloadingMaxNumber, failedTryAgain, timeout);
|
||||||
{
|
|
||||||
List<BundleInfo> downloadList = new List<BundleInfo>();
|
|
||||||
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
else if (_playMode == EPlayMode.HostPlayMode)
|
|
||||||
{
|
|
||||||
return _hostPlayModeImpl.CreatePatchDownloaderByAll(downloadingMaxNumber, failedTryAgain, timeout);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -775,26 +674,15 @@ namespace YooAsset
|
||||||
public PatchDownloaderOperation CreateBundleDownloader(string[] locations, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
public PatchDownloaderOperation CreateBundleDownloader(string[] locations, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
if (_playMode == EPlayMode.EditorSimulateMode || _playMode == EPlayMode.OfflinePlayMode)
|
|
||||||
|
List<AssetInfo> assetInfos = new List<AssetInfo>(locations.Length);
|
||||||
|
foreach (var location in locations)
|
||||||
{
|
{
|
||||||
List<BundleInfo> downloadList = new List<BundleInfo>();
|
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
|
||||||
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
assetInfos.Add(assetInfo);
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
else if (_playMode == EPlayMode.HostPlayMode)
|
|
||||||
{
|
|
||||||
List<AssetInfo> assetInfos = new List<AssetInfo>(locations.Length);
|
|
||||||
foreach (var location in locations)
|
|
||||||
{
|
|
||||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
|
|
||||||
assetInfos.Add(assetInfo);
|
|
||||||
}
|
|
||||||
return _hostPlayModeImpl.CreatePatchDownloaderByPaths(assetInfos.ToArray(), downloadingMaxNumber, failedTryAgain, timeout);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return _playModeServices.CreatePatchDownloaderByPaths(assetInfos.ToArray(), downloadingMaxNumber, failedTryAgain, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -807,20 +695,7 @@ namespace YooAsset
|
||||||
public PatchDownloaderOperation CreateBundleDownloader(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
public PatchDownloaderOperation CreateBundleDownloader(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
if (_playMode == EPlayMode.EditorSimulateMode || _playMode == EPlayMode.OfflinePlayMode)
|
return _playModeServices.CreatePatchDownloaderByPaths(assetInfos, downloadingMaxNumber, failedTryAgain, timeout);
|
||||||
{
|
|
||||||
List<BundleInfo> downloadList = new List<BundleInfo>();
|
|
||||||
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
else if (_playMode == EPlayMode.HostPlayMode)
|
|
||||||
{
|
|
||||||
return _hostPlayModeImpl.CreatePatchDownloaderByPaths(assetInfos, downloadingMaxNumber, failedTryAgain, timeout);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -834,7 +709,7 @@ namespace YooAsset
|
||||||
public PatchUnpackerOperation CreatePatchUnpacker(string tag, int unpackingMaxNumber, int failedTryAgain)
|
public PatchUnpackerOperation CreatePatchUnpacker(string tag, int unpackingMaxNumber, int failedTryAgain)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
return CreatePatchUnpacker(new string[] { tag }, unpackingMaxNumber, failedTryAgain);
|
return _playModeServices.CreatePatchUnpackerByTags(new string[] { tag }, unpackingMaxNumber, failedTryAgain, int.MaxValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -846,26 +721,7 @@ namespace YooAsset
|
||||||
public PatchUnpackerOperation CreatePatchUnpacker(string[] tags, int unpackingMaxNumber, int failedTryAgain)
|
public PatchUnpackerOperation CreatePatchUnpacker(string[] tags, int unpackingMaxNumber, int failedTryAgain)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
if (_playMode == EPlayMode.EditorSimulateMode)
|
return _playModeServices.CreatePatchUnpackerByTags(tags, unpackingMaxNumber, failedTryAgain, int.MaxValue);
|
||||||
{
|
|
||||||
List<BundleInfo> downloadList = new List<BundleInfo>();
|
|
||||||
var operation = new PatchUnpackerOperation(downloadList, unpackingMaxNumber, failedTryAgain, int.MaxValue);
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
else if (_playMode == EPlayMode.OfflinePlayMode)
|
|
||||||
{
|
|
||||||
List<BundleInfo> downloadList = new List<BundleInfo>();
|
|
||||||
var operation = new PatchUnpackerOperation(downloadList, unpackingMaxNumber, failedTryAgain, int.MaxValue);
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
else if (_playMode == EPlayMode.HostPlayMode)
|
|
||||||
{
|
|
||||||
return _hostPlayModeImpl.CreatePatchUnpackerByTags(tags, unpackingMaxNumber, failedTryAgain, int.MaxValue);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -876,58 +732,7 @@ namespace YooAsset
|
||||||
public PatchUnpackerOperation CreatePatchUnpacker(int unpackingMaxNumber, int failedTryAgain)
|
public PatchUnpackerOperation CreatePatchUnpacker(int unpackingMaxNumber, int failedTryAgain)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
if (_playMode == EPlayMode.EditorSimulateMode)
|
return _playModeServices.CreatePatchUnpackerByAll(unpackingMaxNumber, failedTryAgain, int.MaxValue);
|
||||||
{
|
|
||||||
List<BundleInfo> downloadList = new List<BundleInfo>();
|
|
||||||
var operation = new PatchUnpackerOperation(downloadList, unpackingMaxNumber, failedTryAgain, int.MaxValue);
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
else if (_playMode == EPlayMode.OfflinePlayMode)
|
|
||||||
{
|
|
||||||
List<BundleInfo> downloadList = new List<BundleInfo>();
|
|
||||||
var operation = new PatchUnpackerOperation(downloadList, unpackingMaxNumber, failedTryAgain, int.MaxValue);
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
else if (_playMode == EPlayMode.HostPlayMode)
|
|
||||||
{
|
|
||||||
return _hostPlayModeImpl.CreatePatchUnpackerByAll(unpackingMaxNumber, failedTryAgain, int.MaxValue);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region 包裹更新
|
|
||||||
/// <summary>
|
|
||||||
/// 创建资源包裹下载器,用于下载更新指定资源版本所有的资源包文件
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="packageVersion">指定更新的包裹版本</param>
|
|
||||||
/// <param name="timeout">超时时间</param>
|
|
||||||
public DownloadPackageOperation DownloadPackageAsync(string packageVersion, int timeout = 60)
|
|
||||||
{
|
|
||||||
DebugCheckInitialize();
|
|
||||||
if (_playMode == EPlayMode.EditorSimulateMode)
|
|
||||||
{
|
|
||||||
var operation = new EditorPlayModeDownloadPackageOperation();
|
|
||||||
OperationSystem.StartOperation(operation);
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
else if (_playMode == EPlayMode.OfflinePlayMode)
|
|
||||||
{
|
|
||||||
var operation = new OfflinePlayModeDownloadPackageOperation();
|
|
||||||
OperationSystem.StartOperation(operation);
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
else if (_playMode == EPlayMode.HostPlayMode)
|
|
||||||
{
|
|
||||||
return _hostPlayModeImpl.DownloadPackageAsync(PackageName, packageVersion, timeout);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
|
@ -86,9 +86,8 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 验证并缓存下载文件
|
/// 验证并缓存下载文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static EVerifyResult VerifyAndCacheDownloadBundleFile(PatchBundle patchBundle, EVerifyLevel verifyLevel)
|
public static EVerifyResult VerifyAndCacheDownloadBundleFile(string tempFilePath, PatchBundle patchBundle, EVerifyLevel verifyLevel)
|
||||||
{
|
{
|
||||||
string tempFilePath = patchBundle.CachedFilePath + ".temp";
|
|
||||||
var verifyResult = VerifyContentInternal(tempFilePath, patchBundle.FileSize, patchBundle.FileCRC, verifyLevel);
|
var verifyResult = VerifyContentInternal(tempFilePath, patchBundle.FileSize, patchBundle.FileCRC, verifyLevel);
|
||||||
if (verifyResult == EVerifyResult.Succeed)
|
if (verifyResult == EVerifyResult.Succeed)
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,6 +6,7 @@ namespace YooAsset
|
||||||
protected enum ESteps
|
protected enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
|
CheckLocalFile,
|
||||||
CheckTempFile,
|
CheckTempFile,
|
||||||
PrepareDownload,
|
PrepareDownload,
|
||||||
CreateResumeDownloader,
|
CreateResumeDownloader,
|
||||||
|
@ -59,7 +60,7 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
_failedTryAgain = failedTryAgain;
|
_failedTryAgain = failedTryAgain;
|
||||||
_timeout = timeout;
|
_timeout = timeout;
|
||||||
_steps = ESteps.CheckTempFile;
|
_steps = ESteps.CheckLocalFile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public abstract void Update();
|
public abstract void Update();
|
||||||
|
|
|
@ -34,10 +34,26 @@ namespace YooAsset
|
||||||
if (IsDone())
|
if (IsDone())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// 检测本地文件
|
// 检测本地正式文件
|
||||||
|
if (_steps == ESteps.CheckLocalFile)
|
||||||
|
{
|
||||||
|
var verifyResult = CacheSystem.VerifyAndCacheLocalBundleFile(_bundleInfo.Bundle, CacheSystem.InitVerifyLevel);
|
||||||
|
if (verifyResult == EVerifyResult.Succeed)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Succeed;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (File.Exists(_bundleInfo.Bundle.CachedFilePath))
|
||||||
|
File.Delete(_bundleInfo.Bundle.CachedFilePath);
|
||||||
|
_steps = ESteps.CheckTempFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检测本地临时文件
|
||||||
if (_steps == ESteps.CheckTempFile)
|
if (_steps == ESteps.CheckTempFile)
|
||||||
{
|
{
|
||||||
var verifyResult = CacheSystem.VerifyAndCacheDownloadBundleFile(_bundleInfo.Bundle, EVerifyLevel.High);
|
var verifyResult = CacheSystem.VerifyAndCacheDownloadBundleFile(_tempFilePath, _bundleInfo.Bundle, EVerifyLevel.High);
|
||||||
if (verifyResult == EVerifyResult.Succeed)
|
if (verifyResult == EVerifyResult.Succeed)
|
||||||
{
|
{
|
||||||
_steps = ESteps.Succeed;
|
_steps = ESteps.Succeed;
|
||||||
|
@ -200,7 +216,7 @@ namespace YooAsset
|
||||||
// 验证下载文件
|
// 验证下载文件
|
||||||
if (_steps == ESteps.VerifyDownload)
|
if (_steps == ESteps.VerifyDownload)
|
||||||
{
|
{
|
||||||
var verifyResult = CacheSystem.VerifyAndCacheDownloadBundleFile(_bundleInfo.Bundle, EVerifyLevel.High);
|
var verifyResult = CacheSystem.VerifyAndCacheDownloadBundleFile(_tempFilePath, _bundleInfo.Bundle, EVerifyLevel.High);
|
||||||
if (verifyResult == EVerifyResult.Succeed)
|
if (verifyResult == EVerifyResult.Succeed)
|
||||||
{
|
{
|
||||||
_lastError = string.Empty;
|
_lastError = string.Empty;
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly PatchManifest _patchManifest;
|
private readonly PatchManifest _patchManifest;
|
||||||
private readonly IQueryServices _queryServices;
|
private readonly IPlayModeServices _playModeServices;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
private readonly ThreadSyncContext _syncContext = new ThreadSyncContext();
|
private readonly ThreadSyncContext _syncContext = new ThreadSyncContext();
|
||||||
|
@ -39,10 +39,10 @@ namespace YooAsset
|
||||||
private int _verifyMaxNum;
|
private int _verifyMaxNum;
|
||||||
private int _verifyTotalCount;
|
private int _verifyTotalCount;
|
||||||
|
|
||||||
public CacheFilesVerifyWithThreadOperation(PatchManifest patchManifest, IQueryServices queryServices)
|
public CacheFilesVerifyWithThreadOperation(PatchManifest patchManifest, IPlayModeServices playModeServices)
|
||||||
{
|
{
|
||||||
_patchManifest = patchManifest;
|
_patchManifest = patchManifest;
|
||||||
_queryServices = queryServices;
|
_playModeServices = playModeServices;
|
||||||
}
|
}
|
||||||
internal override void Start()
|
internal override void Start()
|
||||||
{
|
{
|
||||||
|
@ -79,7 +79,7 @@ namespace YooAsset
|
||||||
if (CacheSystem.IsCached(patchBundle))
|
if (CacheSystem.IsCached(patchBundle))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
bool isBuildinFile = IsBuildinFile(patchBundle);
|
bool isBuildinFile = _playModeServices.IsBuildinPatchBundle(patchBundle);
|
||||||
VerifyInfo verifyInfo = new VerifyInfo(isBuildinFile, patchBundle);
|
VerifyInfo verifyInfo = new VerifyInfo(isBuildinFile, patchBundle);
|
||||||
_waitingList.Add(verifyInfo);
|
_waitingList.Add(verifyInfo);
|
||||||
}
|
}
|
||||||
|
@ -126,13 +126,6 @@ namespace YooAsset
|
||||||
return 1f;
|
return 1f;
|
||||||
return (float)(VerifySuccessList.Count + VerifyFailList.Count) / _verifyTotalCount;
|
return (float)(VerifySuccessList.Count + VerifyFailList.Count) / _verifyTotalCount;
|
||||||
}
|
}
|
||||||
private bool IsBuildinFile(PatchBundle patchBundle)
|
|
||||||
{
|
|
||||||
if (_queryServices == null)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return _queryServices.QueryStreamingAssets(patchBundle.FileName);
|
|
||||||
}
|
|
||||||
private bool VerifyFileWithThread(VerifyInfo verifyInfo)
|
private bool VerifyFileWithThread(VerifyInfo verifyInfo)
|
||||||
{
|
{
|
||||||
return ThreadPool.QueueUserWorkItem(new WaitCallback(VerifyInThread), verifyInfo);
|
return ThreadPool.QueueUserWorkItem(new WaitCallback(VerifyInThread), verifyInfo);
|
||||||
|
@ -181,7 +174,7 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly PatchManifest _patchManifest;
|
private readonly PatchManifest _patchManifest;
|
||||||
private readonly IQueryServices _queryServices;
|
private readonly IPlayModeServices _playModeServices;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
private List<VerifyInfo> _waitingList;
|
private List<VerifyInfo> _waitingList;
|
||||||
|
@ -189,10 +182,10 @@ namespace YooAsset
|
||||||
private int _verifyMaxNum;
|
private int _verifyMaxNum;
|
||||||
private int _verifyTotalCount;
|
private int _verifyTotalCount;
|
||||||
|
|
||||||
public CacheFilesVerifyWithoutThreadOperation(PatchManifest patchManifest, IQueryServices queryServices)
|
public CacheFilesVerifyWithoutThreadOperation(PatchManifest patchManifest, IPlayModeServices playModeServices)
|
||||||
{
|
{
|
||||||
_patchManifest = patchManifest;
|
_patchManifest = patchManifest;
|
||||||
_queryServices = queryServices;
|
_playModeServices = playModeServices;
|
||||||
}
|
}
|
||||||
internal override void Start()
|
internal override void Start()
|
||||||
{
|
{
|
||||||
|
@ -225,7 +218,7 @@ namespace YooAsset
|
||||||
if (CacheSystem.IsCached(patchBundle))
|
if (CacheSystem.IsCached(patchBundle))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
bool isBuildinFile = IsBuildinFile(patchBundle);
|
bool isBuildinFile = _playModeServices.IsBuildinPatchBundle(patchBundle);
|
||||||
VerifyInfo verifyInfo = new VerifyInfo(isBuildinFile, patchBundle);
|
VerifyInfo verifyInfo = new VerifyInfo(isBuildinFile, patchBundle);
|
||||||
_waitingList.Add(verifyInfo);
|
_waitingList.Add(verifyInfo);
|
||||||
}
|
}
|
||||||
|
@ -265,13 +258,6 @@ namespace YooAsset
|
||||||
return 1f;
|
return 1f;
|
||||||
return (float)(VerifySuccessList.Count + VerifyFailList.Count) / _verifyTotalCount;
|
return (float)(VerifySuccessList.Count + VerifyFailList.Count) / _verifyTotalCount;
|
||||||
}
|
}
|
||||||
private bool IsBuildinFile(PatchBundle patchBundle)
|
|
||||||
{
|
|
||||||
if (_queryServices == null)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return _queryServices.QueryStreamingAssets(patchBundle.FileName);
|
|
||||||
}
|
|
||||||
private void VerifyFileWithoutThread(VerifyInfo verifyIno)
|
private void VerifyFileWithoutThread(VerifyInfo verifyIno)
|
||||||
{
|
{
|
||||||
var verifyResult = CacheSystem.VerifyAndCacheLocalBundleFile(verifyIno.VerifyBundle, CacheSystem.InitVerifyLevel);
|
var verifyResult = CacheSystem.VerifyAndCacheLocalBundleFile(verifyIno.VerifyBundle, CacheSystem.InitVerifyLevel);
|
||||||
|
|
|
@ -86,9 +86,9 @@ namespace YooAsset
|
||||||
if (_steps == ESteps.StartVerifyOperation)
|
if (_steps == ESteps.StartVerifyOperation)
|
||||||
{
|
{
|
||||||
#if UNITY_WEBGL
|
#if UNITY_WEBGL
|
||||||
_verifyOperation = new CacheFilesVerifyWithoutThreadOperation(_impl.LocalPatchManifest, _impl.QueryServices);
|
_verifyOperation = new CacheFilesVerifyWithoutThreadOperation(_impl.ActivePatchManifest, _impl);
|
||||||
#else
|
#else
|
||||||
_verifyOperation = new CacheFilesVerifyWithThreadOperation(_impl.ActivePatchManifest, _impl.QueryServices);
|
_verifyOperation = new CacheFilesVerifyWithThreadOperation(_impl.ActivePatchManifest, _impl);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
OperationSystem.StartOperation(_verifyOperation);
|
OperationSystem.StartOperation(_verifyOperation);
|
||||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
|
/*
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
public abstract class DownloadPackageOperation : AsyncOperationBase
|
public abstract class DownloadPackageOperation : AsyncOperationBase
|
||||||
|
@ -214,4 +215,5 @@ namespace YooAsset
|
||||||
return _impl.ConvertToDownloadList(downloadList);
|
return _impl.ConvertToDownloadList(downloadList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
|
@ -70,7 +70,7 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
var manifest = _deserializer.Manifest;
|
var manifest = _deserializer.Manifest;
|
||||||
InitializedPackageVersion = manifest.PackageVersion;
|
InitializedPackageVersion = manifest.PackageVersion;
|
||||||
_impl.SetActivePatchManifest(manifest);
|
_impl.ActivePatchManifest = manifest;
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Succeed;
|
Status = EOperationStatus.Succeed;
|
||||||
}
|
}
|
||||||
|
@ -160,7 +160,7 @@ namespace YooAsset
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
InitializedPackageVersion = manifest.PackageVersion;
|
InitializedPackageVersion = manifest.PackageVersion;
|
||||||
_impl.SetActivePatchManifest(manifest);
|
_impl.ActivePatchManifest = manifest;
|
||||||
_steps = ESteps.StartVerifyOperation;
|
_steps = ESteps.StartVerifyOperation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -168,9 +168,9 @@ namespace YooAsset
|
||||||
if (_steps == ESteps.StartVerifyOperation)
|
if (_steps == ESteps.StartVerifyOperation)
|
||||||
{
|
{
|
||||||
#if UNITY_WEBGL
|
#if UNITY_WEBGL
|
||||||
_verifyOperation = new CacheFilesVerifyWithoutThreadOperation(_impl.AppPatchManifest, null);
|
_verifyOperation = new CacheFilesVerifyWithoutThreadOperation(_impl.ActivePatchManifest, _impl);
|
||||||
#else
|
#else
|
||||||
_verifyOperation = new CacheFilesVerifyWithThreadOperation(_impl.ActivePatchManifest, null);
|
_verifyOperation = new CacheFilesVerifyWithThreadOperation(_impl.ActivePatchManifest, _impl);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
OperationSystem.StartOperation(_verifyOperation);
|
OperationSystem.StartOperation(_verifyOperation);
|
||||||
|
@ -263,7 +263,7 @@ namespace YooAsset
|
||||||
if (manifest != null)
|
if (manifest != null)
|
||||||
{
|
{
|
||||||
InitializedPackageVersion = manifest.PackageVersion;
|
InitializedPackageVersion = manifest.PackageVersion;
|
||||||
_impl.SetActivePatchManifest(manifest);
|
_impl.ActivePatchManifest = manifest;
|
||||||
_steps = ESteps.StartVerifyOperation;
|
_steps = ESteps.StartVerifyOperation;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -332,7 +332,7 @@ namespace YooAsset
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
InitializedPackageVersion = manifest.PackageVersion;
|
InitializedPackageVersion = manifest.PackageVersion;
|
||||||
_impl.SetActivePatchManifest(manifest);
|
_impl.ActivePatchManifest = manifest;
|
||||||
_steps = ESteps.StartVerifyOperation;
|
_steps = ESteps.StartVerifyOperation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -340,9 +340,9 @@ namespace YooAsset
|
||||||
if (_steps == ESteps.StartVerifyOperation)
|
if (_steps == ESteps.StartVerifyOperation)
|
||||||
{
|
{
|
||||||
#if UNITY_WEBGL
|
#if UNITY_WEBGL
|
||||||
_verifyOperation = new CacheFilesVerifyWithoutThreadOperation(_impl.LocalPatchManifest, _impl.QueryServices);
|
_verifyOperation = new CacheFilesVerifyWithoutThreadOperation(_impl.ActivePatchManifest, _impl);
|
||||||
#else
|
#else
|
||||||
_verifyOperation = new CacheFilesVerifyWithThreadOperation(_impl.ActivePatchManifest, _impl.QueryServices);
|
_verifyOperation = new CacheFilesVerifyWithThreadOperation(_impl.ActivePatchManifest, _impl);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
OperationSystem.StartOperation(_verifyOperation);
|
OperationSystem.StartOperation(_verifyOperation);
|
||||||
|
|
|
@ -68,6 +68,8 @@ namespace YooAsset
|
||||||
private readonly HostPlayModeImpl _impl;
|
private readonly HostPlayModeImpl _impl;
|
||||||
private readonly string _packageName;
|
private readonly string _packageName;
|
||||||
private readonly string _packageVersion;
|
private readonly string _packageVersion;
|
||||||
|
private bool _autoSaveManifest;
|
||||||
|
private bool _autoActiveManifest;
|
||||||
private readonly int _timeout;
|
private readonly int _timeout;
|
||||||
private UnityWebDataRequester _downloader1;
|
private UnityWebDataRequester _downloader1;
|
||||||
private UnityWebDataRequester _downloader2;
|
private UnityWebDataRequester _downloader2;
|
||||||
|
@ -76,13 +78,16 @@ namespace YooAsset
|
||||||
|
|
||||||
private string _cacheManifestHash;
|
private string _cacheManifestHash;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
private byte[] _fileBytes = null;
|
||||||
private float _verifyTime;
|
private float _verifyTime;
|
||||||
|
|
||||||
internal HostPlayModeUpdatePackageManifestOperation(HostPlayModeImpl impl, string packageName, string packageVersion, int timeout)
|
internal HostPlayModeUpdatePackageManifestOperation(HostPlayModeImpl impl, string packageName, string packageVersion, bool autoSaveManifest, bool autoActiveManifest, int timeout)
|
||||||
{
|
{
|
||||||
_impl = impl;
|
_impl = impl;
|
||||||
_packageName = packageName;
|
_packageName = packageName;
|
||||||
_packageVersion = packageVersion;
|
_packageVersion = packageVersion;
|
||||||
|
_autoSaveManifest = autoSaveManifest;
|
||||||
|
_autoActiveManifest = autoActiveManifest;
|
||||||
_timeout = timeout;
|
_timeout = timeout;
|
||||||
}
|
}
|
||||||
internal override void Start()
|
internal override void Start()
|
||||||
|
@ -171,16 +176,25 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 保存文件到沙盒内
|
|
||||||
byte[] bytesData = _downloader2.GetData();
|
byte[] bytesData = _downloader2.GetData();
|
||||||
string savePath = PersistentHelper.GetCacheManifestFilePath(_packageName);
|
|
||||||
FileUtility.CreateFile(savePath, bytesData);
|
// 保存文件到沙盒内
|
||||||
|
if (_autoSaveManifest)
|
||||||
|
{
|
||||||
|
string savePath = PersistentHelper.GetCacheManifestFilePath(_packageName);
|
||||||
|
FileUtility.CreateFile(savePath, bytesData);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_fileBytes = bytesData;
|
||||||
|
}
|
||||||
|
|
||||||
// 解析二进制数据
|
// 解析二进制数据
|
||||||
_deserializer = new DeserializeManifestOperation(bytesData);
|
_deserializer = new DeserializeManifestOperation(bytesData);
|
||||||
OperationSystem.StartOperation(_deserializer);
|
OperationSystem.StartOperation(_deserializer);
|
||||||
_steps = ESteps.CheckDeserializeWebManifest;
|
_steps = ESteps.CheckDeserializeWebManifest;
|
||||||
}
|
}
|
||||||
|
|
||||||
_downloader2.Dispose();
|
_downloader2.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +205,11 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
if (_deserializer.Status == EOperationStatus.Succeed)
|
if (_deserializer.Status == EOperationStatus.Succeed)
|
||||||
{
|
{
|
||||||
_impl.SetActivePatchManifest(_deserializer.Manifest);
|
if (_autoActiveManifest)
|
||||||
|
{
|
||||||
|
_impl.ActivePatchManifest = _deserializer.Manifest;
|
||||||
|
}
|
||||||
|
|
||||||
FoundNewManifest = true;
|
FoundNewManifest = true;
|
||||||
_steps = ESteps.StartVerifyOperation;
|
_steps = ESteps.StartVerifyOperation;
|
||||||
}
|
}
|
||||||
|
@ -207,9 +225,9 @@ namespace YooAsset
|
||||||
if (_steps == ESteps.StartVerifyOperation)
|
if (_steps == ESteps.StartVerifyOperation)
|
||||||
{
|
{
|
||||||
#if UNITY_WEBGL
|
#if UNITY_WEBGL
|
||||||
_verifyOperation = new CacheFilesVerifyWithoutThreadOperation(_impl.LocalPatchManifest, _impl.QueryServices);
|
_verifyOperation = new CacheFilesVerifyWithoutThreadOperation(_deserializer.Manifest, _impl);
|
||||||
#else
|
#else
|
||||||
_verifyOperation = new CacheFilesVerifyWithThreadOperation(_impl.ActivePatchManifest, _impl.QueryServices);
|
_verifyOperation = new CacheFilesVerifyWithThreadOperation(_deserializer.Manifest, _impl);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
OperationSystem.StartOperation(_verifyOperation);
|
OperationSystem.StartOperation(_verifyOperation);
|
||||||
|
@ -230,6 +248,37 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 手动保存清单文件
|
||||||
|
/// </summary>
|
||||||
|
public void SaveManifest()
|
||||||
|
{
|
||||||
|
if (_autoSaveManifest == false)
|
||||||
|
{
|
||||||
|
if (_fileBytes != null)
|
||||||
|
{
|
||||||
|
_autoSaveManifest = true;
|
||||||
|
string savePath = PersistentHelper.GetCacheManifestFilePath(_packageName);
|
||||||
|
FileUtility.CreateFile(savePath, _fileBytes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 手动激活清单文件
|
||||||
|
/// </summary>
|
||||||
|
public void ActiveManifest()
|
||||||
|
{
|
||||||
|
if (_autoActiveManifest == false)
|
||||||
|
{
|
||||||
|
if (_deserializer.Status == EOperationStatus.Succeed)
|
||||||
|
{
|
||||||
|
_autoActiveManifest = true;
|
||||||
|
_impl.ActivePatchManifest = _deserializer.Manifest;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取补丁清单请求地址
|
/// 获取补丁清单请求地址
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -59,17 +59,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 int _timeout;
|
|
||||||
private readonly bool _appendTimeTicks;
|
private readonly bool _appendTimeTicks;
|
||||||
|
private readonly int _timeout;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
private UnityWebDataRequester _downloader;
|
private UnityWebDataRequester _downloader;
|
||||||
|
|
||||||
internal HostPlayModeUpdatePackageVersionOperation(HostPlayModeImpl impl, string packageName, int timeout, bool appendTimeTicks)
|
internal HostPlayModeUpdatePackageVersionOperation(HostPlayModeImpl impl, string packageName, bool appendTimeTicks, int timeout)
|
||||||
{
|
{
|
||||||
_impl = impl;
|
_impl = impl;
|
||||||
_packageName = packageName;
|
_packageName = packageName;
|
||||||
_timeout = timeout;
|
|
||||||
_appendTimeTicks = appendTimeTicks;
|
_appendTimeTicks = appendTimeTicks;
|
||||||
|
_timeout = timeout;
|
||||||
}
|
}
|
||||||
internal override void Start()
|
internal override void Start()
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,37 +4,98 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
internal class EditorSimulateModeImpl : IBundleServices
|
internal class EditorSimulateModeImpl : IPlayModeServices, IBundleServices
|
||||||
{
|
{
|
||||||
public PatchManifest ActivePatchManifest { private set; get; }
|
private PatchManifest _activePatchManifest;
|
||||||
|
private string _packageName;
|
||||||
private bool _locationToLower;
|
private bool _locationToLower;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步初始化
|
/// 异步初始化
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public InitializationOperation InitializeAsync(bool locationToLower, string simulatePatchManifestPath)
|
public InitializationOperation InitializeAsync(string packageName, bool locationToLower, string simulatePatchManifestPath)
|
||||||
{
|
{
|
||||||
|
_packageName = packageName;
|
||||||
_locationToLower = locationToLower;
|
_locationToLower = locationToLower;
|
||||||
var operation = new EditorSimulateModeInitializationOperation(this, simulatePatchManifestPath);
|
var operation = new EditorSimulateModeInitializationOperation(this, simulatePatchManifestPath);
|
||||||
OperationSystem.StartOperation(operation);
|
OperationSystem.StartOperation(operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
#region IPlayModeServices接口
|
||||||
/// 获取包裹的版本信息
|
public PatchManifest ActivePatchManifest
|
||||||
/// </summary>
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_activePatchManifest = value;
|
||||||
|
_activePatchManifest.InitAssetPathMapping(_locationToLower);
|
||||||
|
}
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _activePatchManifest;
|
||||||
|
}
|
||||||
|
}
|
||||||
public string GetPackageVersion()
|
public string GetPackageVersion()
|
||||||
{
|
{
|
||||||
if (ActivePatchManifest == null)
|
if (_activePatchManifest == null)
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
return ActivePatchManifest.PackageVersion;
|
return _activePatchManifest.PackageVersion;
|
||||||
|
}
|
||||||
|
public bool IsBuildinPatchBundle(PatchBundle patchBundle)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void SetActivePatchManifest(PatchManifest patchManifest)
|
UpdatePackageVersionOperation IPlayModeServices.UpdatePackageVersionAsync(bool appendTimeTicks, int timeout)
|
||||||
{
|
{
|
||||||
ActivePatchManifest = patchManifest;
|
var operation = new EditorPlayModeUpdatePackageVersionOperation();
|
||||||
ActivePatchManifest.InitAssetPathMapping(_locationToLower);
|
OperationSystem.StartOperation(operation);
|
||||||
|
return operation;
|
||||||
}
|
}
|
||||||
|
UpdatePackageManifestOperation IPlayModeServices.UpdatePackageManifestAsync(string packageVersion, bool autoSaveManifest, bool autoActiveManifest, int timeout)
|
||||||
|
{
|
||||||
|
var operation = new EditorPlayModeUpdatePackageManifestOperation();
|
||||||
|
OperationSystem.StartOperation(operation);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
CheckPackageContentsOperation IPlayModeServices.CheckPackageContentsAsync()
|
||||||
|
{
|
||||||
|
var operation = new EditorSimulateModeCheckPackageContentsOperation();
|
||||||
|
OperationSystem.StartOperation(operation);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
|
||||||
|
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||||
|
{
|
||||||
|
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||||
|
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||||
|
{
|
||||||
|
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||||
|
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByPaths(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||||
|
{
|
||||||
|
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||||
|
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout)
|
||||||
|
{
|
||||||
|
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||||
|
var operation = new PatchUnpackerOperation(downloadList, upackingMaxNumber, failedTryAgain, int.MaxValue);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout)
|
||||||
|
{
|
||||||
|
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||||
|
var operation = new PatchUnpackerOperation(downloadList, upackingMaxNumber, failedTryAgain, int.MaxValue);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region IBundleServices接口
|
#region IBundleServices接口
|
||||||
BundleInfo IBundleServices.GetBundleInfo(AssetInfo assetInfo)
|
BundleInfo IBundleServices.GetBundleInfo(AssetInfo assetInfo)
|
||||||
|
@ -43,7 +104,7 @@ namespace YooAsset
|
||||||
throw new Exception("Should never get here !");
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
// 注意:如果补丁清单里未找到资源包会抛出异常!
|
// 注意:如果补丁清单里未找到资源包会抛出异常!
|
||||||
var patchBundle = ActivePatchManifest.GetMainPatchBundle(assetInfo.AssetPath);
|
var patchBundle = _activePatchManifest.GetMainPatchBundle(assetInfo.AssetPath);
|
||||||
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromEditor, assetInfo.AssetPath);
|
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromEditor, assetInfo.AssetPath);
|
||||||
return bundleInfo;
|
return bundleInfo;
|
||||||
}
|
}
|
||||||
|
@ -53,34 +114,34 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
AssetInfo[] IBundleServices.GetAssetInfos(string[] tags)
|
AssetInfo[] IBundleServices.GetAssetInfos(string[] tags)
|
||||||
{
|
{
|
||||||
return ActivePatchManifest.GetAssetsInfoByTags(tags);
|
return _activePatchManifest.GetAssetsInfoByTags(tags);
|
||||||
}
|
}
|
||||||
PatchAsset IBundleServices.TryGetPatchAsset(string assetPath)
|
PatchAsset IBundleServices.TryGetPatchAsset(string assetPath)
|
||||||
{
|
{
|
||||||
if (ActivePatchManifest.TryGetPatchAsset(assetPath, out PatchAsset patchAsset))
|
if (_activePatchManifest.TryGetPatchAsset(assetPath, out PatchAsset patchAsset))
|
||||||
return patchAsset;
|
return patchAsset;
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
string IBundleServices.MappingToAssetPath(string location)
|
string IBundleServices.MappingToAssetPath(string location)
|
||||||
{
|
{
|
||||||
return ActivePatchManifest.MappingToAssetPath(location);
|
return _activePatchManifest.MappingToAssetPath(location);
|
||||||
}
|
}
|
||||||
string IBundleServices.TryMappingToAssetPath(string location)
|
string IBundleServices.TryMappingToAssetPath(string location)
|
||||||
{
|
{
|
||||||
return ActivePatchManifest.TryMappingToAssetPath(location);
|
return _activePatchManifest.TryMappingToAssetPath(location);
|
||||||
}
|
}
|
||||||
string IBundleServices.GetPackageName()
|
string IBundleServices.GetPackageName()
|
||||||
{
|
{
|
||||||
return ActivePatchManifest.PackageName;
|
return _packageName;
|
||||||
}
|
}
|
||||||
bool IBundleServices.IsIncludeBundleFile(string fileName)
|
bool IBundleServices.IsIncludeBundleFile(string fileName)
|
||||||
{
|
{
|
||||||
return ActivePatchManifest.IsIncludeBundleFile(fileName);
|
return _activePatchManifest.IsIncludeBundleFile(fileName);
|
||||||
}
|
}
|
||||||
bool IBundleServices.IsServicesValid()
|
bool IBundleServices.IsServicesValid()
|
||||||
{
|
{
|
||||||
return ActivePatchManifest != null;
|
return _activePatchManifest != null;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,100 +1,137 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
internal class HostPlayModeImpl : IBundleServices
|
internal class HostPlayModeImpl : IPlayModeServices, IBundleServices
|
||||||
{
|
{
|
||||||
// 补丁清单
|
private PatchManifest _activePatchManifest;
|
||||||
public PatchManifest ActivePatchManifest { private set; get; }
|
|
||||||
|
|
||||||
// 参数相关
|
// 参数相关
|
||||||
|
private string _packageName;
|
||||||
private bool _locationToLower;
|
private bool _locationToLower;
|
||||||
private string _defaultHostServer;
|
private string _defaultHostServer;
|
||||||
private string _fallbackHostServer;
|
private string _fallbackHostServer;
|
||||||
public IQueryServices QueryServices { private set; get; }
|
private IQueryServices _queryServices;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步初始化
|
/// 异步初始化
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public InitializationOperation InitializeAsync(bool locationToLower, string defaultHostServer, string fallbackHostServer, IQueryServices queryServices, string packageName)
|
public InitializationOperation InitializeAsync(string packageName, bool locationToLower, string defaultHostServer, string fallbackHostServer, IQueryServices queryServices)
|
||||||
{
|
{
|
||||||
|
_packageName = packageName;
|
||||||
_locationToLower = locationToLower;
|
_locationToLower = locationToLower;
|
||||||
_defaultHostServer = defaultHostServer;
|
_defaultHostServer = defaultHostServer;
|
||||||
_fallbackHostServer = fallbackHostServer;
|
_fallbackHostServer = fallbackHostServer;
|
||||||
QueryServices = queryServices;
|
_queryServices = queryServices;
|
||||||
|
|
||||||
var operation = new HostPlayModeInitializationOperation(this, packageName);
|
var operation = new HostPlayModeInitializationOperation(this, packageName);
|
||||||
OperationSystem.StartOperation(operation);
|
OperationSystem.StartOperation(operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
// WEB相关
|
||||||
/// 获取包裹的版本信息
|
public string GetPatchDownloadMainURL(string fileName)
|
||||||
/// </summary>
|
{
|
||||||
|
return $"{_defaultHostServer}/{fileName}";
|
||||||
|
}
|
||||||
|
public string GetPatchDownloadFallbackURL(string fileName)
|
||||||
|
{
|
||||||
|
return $"{_fallbackHostServer}/{fileName}";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 下载相关
|
||||||
|
private List<BundleInfo> ConvertToDownloadList(List<PatchBundle> downloadList)
|
||||||
|
{
|
||||||
|
List<BundleInfo> result = new List<BundleInfo>(downloadList.Count);
|
||||||
|
foreach (var patchBundle in downloadList)
|
||||||
|
{
|
||||||
|
var bundleInfo = ConvertToDownloadInfo(patchBundle);
|
||||||
|
result.Add(bundleInfo);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
private BundleInfo ConvertToDownloadInfo(PatchBundle patchBundle)
|
||||||
|
{
|
||||||
|
string remoteMainURL = GetPatchDownloadMainURL(patchBundle.FileName);
|
||||||
|
string remoteFallbackURL = GetPatchDownloadFallbackURL(patchBundle.FileName);
|
||||||
|
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromRemote, remoteMainURL, remoteFallbackURL);
|
||||||
|
return bundleInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 解压相关
|
||||||
|
private List<BundleInfo> ConvertToUnpackList(List<PatchBundle> unpackList)
|
||||||
|
{
|
||||||
|
List<BundleInfo> result = new List<BundleInfo>(unpackList.Count);
|
||||||
|
foreach (var patchBundle in unpackList)
|
||||||
|
{
|
||||||
|
var bundleInfo = ConvertToUnpackInfo(patchBundle);
|
||||||
|
result.Add(bundleInfo);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
public static BundleInfo ConvertToUnpackInfo(PatchBundle patchBundle)
|
||||||
|
{
|
||||||
|
// 注意:我们把流加载路径指定为远端下载地址
|
||||||
|
string streamingPath = PathHelper.ConvertToWWWPath(patchBundle.StreamingFilePath);
|
||||||
|
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromStreaming, streamingPath, streamingPath);
|
||||||
|
return bundleInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region IPlayModeServices接口
|
||||||
|
public PatchManifest ActivePatchManifest
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_activePatchManifest = value;
|
||||||
|
_activePatchManifest.InitAssetPathMapping(_locationToLower);
|
||||||
|
}
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _activePatchManifest;
|
||||||
|
}
|
||||||
|
}
|
||||||
public string GetPackageVersion()
|
public string GetPackageVersion()
|
||||||
{
|
{
|
||||||
if (ActivePatchManifest == null)
|
if (_activePatchManifest == null)
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
return ActivePatchManifest.PackageVersion;
|
return _activePatchManifest.PackageVersion;
|
||||||
|
}
|
||||||
|
public bool IsBuildinPatchBundle(PatchBundle patchBundle)
|
||||||
|
{
|
||||||
|
return _queryServices.QueryStreamingAssets(patchBundle.FileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
UpdatePackageVersionOperation IPlayModeServices.UpdatePackageVersionAsync(bool appendTimeTicks, int timeout)
|
||||||
/// 异步更新资源版本号
|
|
||||||
/// </summary>
|
|
||||||
public UpdatePackageVersionOperation UpdatePackageVersionAsync(string packageName, int timeout, bool appendTimeTicks)
|
|
||||||
{
|
{
|
||||||
var operation = new HostPlayModeUpdatePackageVersionOperation(this, packageName, timeout, appendTimeTicks);
|
var operation = new HostPlayModeUpdatePackageVersionOperation(this, _packageName, appendTimeTicks, timeout);
|
||||||
|
OperationSystem.StartOperation(operation);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
UpdatePackageManifestOperation IPlayModeServices.UpdatePackageManifestAsync(string packageVersion, bool autoSaveManifest, bool autoActiveManifest, int timeout)
|
||||||
|
{
|
||||||
|
var operation = new HostPlayModeUpdatePackageManifestOperation(this, _packageName, packageVersion, autoSaveManifest, autoActiveManifest, timeout);
|
||||||
|
OperationSystem.StartOperation(operation);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
CheckPackageContentsOperation IPlayModeServices.CheckPackageContentsAsync()
|
||||||
|
{
|
||||||
|
var operation = new HostPlayModeCheckPackageContentsOperation(this, _packageName);
|
||||||
OperationSystem.StartOperation(operation);
|
OperationSystem.StartOperation(operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||||
/// 异步更新补丁清单
|
|
||||||
/// </summary>
|
|
||||||
public UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageName, string packageVersion, int timeout)
|
|
||||||
{
|
{
|
||||||
var operation = new HostPlayModeUpdatePackageManifestOperation(this, packageName, packageVersion, timeout);
|
|
||||||
OperationSystem.StartOperation(operation);
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 检查本地包裹内容的完整性
|
|
||||||
/// </summary>
|
|
||||||
public CheckPackageContentsOperation CheckPackageContentsAsync(string packageName)
|
|
||||||
{
|
|
||||||
var operation = new HostPlayModeCheckPackageContentsOperation(this, packageName);
|
|
||||||
OperationSystem.StartOperation(operation);
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 异步更新资源包裹
|
|
||||||
/// </summary>
|
|
||||||
public DownloadPackageOperation DownloadPackageAsync(string packageName, string packageVersion, int timeout)
|
|
||||||
{
|
|
||||||
var operation = new HostPlayModeDownloadPackageOperation(this, packageName, packageVersion, timeout);
|
|
||||||
OperationSystem.StartOperation(operation);
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 创建下载器
|
|
||||||
/// </summary>
|
|
||||||
public PatchDownloaderOperation CreatePatchDownloaderByAll(int fileLoadingMaxNumber, int failedTryAgain, int timeout)
|
|
||||||
{
|
|
||||||
YooLogger.Log($"Create patch downloader : {ActivePatchManifest.PackageName} {ActivePatchManifest.PackageVersion}");
|
|
||||||
List<BundleInfo> downloadList = GetDownloadListByAll();
|
List<BundleInfo> downloadList = GetDownloadListByAll();
|
||||||
var operation = new PatchDownloaderOperation(downloadList, fileLoadingMaxNumber, failedTryAgain, timeout);
|
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
private List<BundleInfo> GetDownloadListByAll()
|
private List<BundleInfo> GetDownloadListByAll()
|
||||||
{
|
{
|
||||||
List<PatchBundle> downloadList = new List<PatchBundle>(1000);
|
List<PatchBundle> downloadList = new List<PatchBundle>(1000);
|
||||||
foreach (var patchBundle in ActivePatchManifest.BundleList)
|
foreach (var patchBundle in _activePatchManifest.BundleList)
|
||||||
{
|
{
|
||||||
// 忽略缓存文件
|
// 忽略缓存文件
|
||||||
if (CacheSystem.IsCached(patchBundle))
|
if (CacheSystem.IsCached(patchBundle))
|
||||||
|
@ -110,20 +147,16 @@ namespace YooAsset
|
||||||
return ConvertToDownloadList(downloadList);
|
return ConvertToDownloadList(downloadList);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||||
/// 创建下载器
|
|
||||||
/// </summary>
|
|
||||||
public PatchDownloaderOperation CreatePatchDownloaderByTags(string[] tags, int fileLoadingMaxNumber, int failedTryAgain, int timeout)
|
|
||||||
{
|
{
|
||||||
YooLogger.Log($"Create patch downloader : {ActivePatchManifest.PackageName} {ActivePatchManifest.PackageVersion}");
|
|
||||||
List<BundleInfo> downloadList = GetDownloadListByTags(tags);
|
List<BundleInfo> downloadList = GetDownloadListByTags(tags);
|
||||||
var operation = new PatchDownloaderOperation(downloadList, fileLoadingMaxNumber, failedTryAgain, timeout);
|
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
private List<BundleInfo> GetDownloadListByTags(string[] tags)
|
private List<BundleInfo> GetDownloadListByTags(string[] tags)
|
||||||
{
|
{
|
||||||
List<PatchBundle> downloadList = new List<PatchBundle>(1000);
|
List<PatchBundle> downloadList = new List<PatchBundle>(1000);
|
||||||
foreach (var patchBundle in ActivePatchManifest.BundleList)
|
foreach (var patchBundle in _activePatchManifest.BundleList)
|
||||||
{
|
{
|
||||||
// 忽略缓存文件
|
// 忽略缓存文件
|
||||||
if (CacheSystem.IsCached(patchBundle))
|
if (CacheSystem.IsCached(patchBundle))
|
||||||
|
@ -151,14 +184,10 @@ namespace YooAsset
|
||||||
return ConvertToDownloadList(downloadList);
|
return ConvertToDownloadList(downloadList);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByPaths(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||||
/// 创建下载器
|
|
||||||
/// </summary>
|
|
||||||
public PatchDownloaderOperation CreatePatchDownloaderByPaths(AssetInfo[] assetInfos, int fileLoadingMaxNumber, int failedTryAgain, int timeout)
|
|
||||||
{
|
{
|
||||||
YooLogger.Log($"Create patch downloader : {ActivePatchManifest.PackageName} {ActivePatchManifest.PackageVersion}");
|
|
||||||
List<BundleInfo> downloadList = GetDownloadListByPaths(assetInfos);
|
List<BundleInfo> downloadList = GetDownloadListByPaths(assetInfos);
|
||||||
var operation = new PatchDownloaderOperation(downloadList, fileLoadingMaxNumber, failedTryAgain, timeout);
|
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
private List<BundleInfo> GetDownloadListByPaths(AssetInfo[] assetInfos)
|
private List<BundleInfo> GetDownloadListByPaths(AssetInfo[] assetInfos)
|
||||||
|
@ -174,12 +203,12 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
// 注意:如果补丁清单里未找到资源包会抛出异常!
|
// 注意:如果补丁清单里未找到资源包会抛出异常!
|
||||||
PatchBundle mainBundle = ActivePatchManifest.GetMainPatchBundle(assetInfo.AssetPath);
|
PatchBundle mainBundle = _activePatchManifest.GetMainPatchBundle(assetInfo.AssetPath);
|
||||||
if (checkList.Contains(mainBundle) == false)
|
if (checkList.Contains(mainBundle) == false)
|
||||||
checkList.Add(mainBundle);
|
checkList.Add(mainBundle);
|
||||||
|
|
||||||
// 注意:如果补丁清单里未找到资源包会抛出异常!
|
// 注意:如果补丁清单里未找到资源包会抛出异常!
|
||||||
PatchBundle[] dependBundles = ActivePatchManifest.GetAllDependencies(assetInfo.AssetPath);
|
PatchBundle[] dependBundles = _activePatchManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||||
foreach (var dependBundle in dependBundles)
|
foreach (var dependBundle in dependBundles)
|
||||||
{
|
{
|
||||||
if (checkList.Contains(dependBundle) == false)
|
if (checkList.Contains(dependBundle) == false)
|
||||||
|
@ -204,20 +233,16 @@ namespace YooAsset
|
||||||
return ConvertToDownloadList(downloadList);
|
return ConvertToDownloadList(downloadList);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout)
|
||||||
/// 创建解压器
|
|
||||||
/// </summary>
|
|
||||||
public PatchUnpackerOperation CreatePatchUnpackerByTags(string[] tags, int fileUpackingMaxNumber, int failedTryAgain, int timeout)
|
|
||||||
{
|
{
|
||||||
YooLogger.Log($"Create patch unpacker : {ActivePatchManifest.PackageName} {ActivePatchManifest.PackageVersion}");
|
|
||||||
List<BundleInfo> unpcakList = GetUnpackListByTags(tags);
|
List<BundleInfo> unpcakList = GetUnpackListByTags(tags);
|
||||||
var operation = new PatchUnpackerOperation(unpcakList, fileUpackingMaxNumber, failedTryAgain, timeout);
|
var operation = new PatchUnpackerOperation(unpcakList, upackingMaxNumber, failedTryAgain, timeout);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
private List<BundleInfo> GetUnpackListByTags(string[] tags)
|
private List<BundleInfo> GetUnpackListByTags(string[] tags)
|
||||||
{
|
{
|
||||||
List<PatchBundle> downloadList = new List<PatchBundle>(1000);
|
List<PatchBundle> downloadList = new List<PatchBundle>(1000);
|
||||||
foreach (var patchBundle in ActivePatchManifest.BundleList)
|
foreach (var patchBundle in _activePatchManifest.BundleList)
|
||||||
{
|
{
|
||||||
// 忽略缓存文件
|
// 忽略缓存文件
|
||||||
if (CacheSystem.IsCached(patchBundle))
|
if (CacheSystem.IsCached(patchBundle))
|
||||||
|
@ -236,20 +261,16 @@ namespace YooAsset
|
||||||
return ConvertToUnpackList(downloadList);
|
return ConvertToUnpackList(downloadList);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout)
|
||||||
/// 创建解压器
|
|
||||||
/// </summary>
|
|
||||||
public PatchUnpackerOperation CreatePatchUnpackerByAll(int fileUpackingMaxNumber, int failedTryAgain, int timeout)
|
|
||||||
{
|
{
|
||||||
YooLogger.Log($"Create patch unpacker : {ActivePatchManifest.PackageName} {ActivePatchManifest.PackageVersion}");
|
|
||||||
List<BundleInfo> unpcakList = GetUnpackListByAll();
|
List<BundleInfo> unpcakList = GetUnpackListByAll();
|
||||||
var operation = new PatchUnpackerOperation(unpcakList, fileUpackingMaxNumber, failedTryAgain, timeout);
|
var operation = new PatchUnpackerOperation(unpcakList, upackingMaxNumber, failedTryAgain, timeout);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
private List<BundleInfo> GetUnpackListByAll()
|
private List<BundleInfo> GetUnpackListByAll()
|
||||||
{
|
{
|
||||||
List<PatchBundle> downloadList = new List<PatchBundle>(1000);
|
List<PatchBundle> downloadList = new List<PatchBundle>(1000);
|
||||||
foreach (var patchBundle in ActivePatchManifest.BundleList)
|
foreach (var patchBundle in _activePatchManifest.BundleList)
|
||||||
{
|
{
|
||||||
// 忽略缓存文件
|
// 忽略缓存文件
|
||||||
if (CacheSystem.IsCached(patchBundle))
|
if (CacheSystem.IsCached(patchBundle))
|
||||||
|
@ -263,64 +284,7 @@ namespace YooAsset
|
||||||
|
|
||||||
return ConvertToUnpackList(downloadList);
|
return ConvertToUnpackList(downloadList);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
// WEB相关
|
|
||||||
public string GetPatchDownloadMainURL(string fileName)
|
|
||||||
{
|
|
||||||
return $"{_defaultHostServer}/{fileName}";
|
|
||||||
}
|
|
||||||
public string GetPatchDownloadFallbackURL(string fileName)
|
|
||||||
{
|
|
||||||
return $"{_fallbackHostServer}/{fileName}";
|
|
||||||
}
|
|
||||||
|
|
||||||
// 下载相关
|
|
||||||
public List<BundleInfo> ConvertToDownloadList(List<PatchBundle> downloadList)
|
|
||||||
{
|
|
||||||
List<BundleInfo> result = new List<BundleInfo>(downloadList.Count);
|
|
||||||
foreach (var patchBundle in downloadList)
|
|
||||||
{
|
|
||||||
var bundleInfo = ConvertToDownloadInfo(patchBundle);
|
|
||||||
result.Add(bundleInfo);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
private BundleInfo ConvertToDownloadInfo(PatchBundle patchBundle)
|
|
||||||
{
|
|
||||||
string remoteMainURL = GetPatchDownloadMainURL(patchBundle.FileName);
|
|
||||||
string remoteFallbackURL = GetPatchDownloadFallbackURL(patchBundle.FileName);
|
|
||||||
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromRemote, remoteMainURL, remoteFallbackURL);
|
|
||||||
return bundleInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 解压相关
|
|
||||||
public List<BundleInfo> ConvertToUnpackList(List<PatchBundle> unpackList)
|
|
||||||
{
|
|
||||||
List<BundleInfo> result = new List<BundleInfo>(unpackList.Count);
|
|
||||||
foreach (var patchBundle in unpackList)
|
|
||||||
{
|
|
||||||
var bundleInfo = ConvertToUnpackInfo(patchBundle);
|
|
||||||
result.Add(bundleInfo);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
public static BundleInfo ConvertToUnpackInfo(PatchBundle patchBundle)
|
|
||||||
{
|
|
||||||
// 注意:我们把流加载路径指定为远端下载地址
|
|
||||||
string streamingPath = PathHelper.ConvertToWWWPath(patchBundle.StreamingFilePath);
|
|
||||||
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromStreaming, streamingPath, streamingPath);
|
|
||||||
return bundleInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void SetActivePatchManifest(PatchManifest patchManifest)
|
|
||||||
{
|
|
||||||
ActivePatchManifest = patchManifest;
|
|
||||||
ActivePatchManifest.InitAssetPathMapping(_locationToLower);
|
|
||||||
}
|
|
||||||
internal bool IsBuildinPatchBundle(PatchBundle patchBundle)
|
|
||||||
{
|
|
||||||
return QueryServices.QueryStreamingAssets(patchBundle.FileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region IBundleServices接口
|
#region IBundleServices接口
|
||||||
private BundleInfo CreateBundleInfo(PatchBundle patchBundle)
|
private BundleInfo CreateBundleInfo(PatchBundle patchBundle)
|
||||||
|
@ -351,7 +315,7 @@ namespace YooAsset
|
||||||
throw new Exception("Should never get here !");
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
// 注意:如果补丁清单里未找到资源包会抛出异常!
|
// 注意:如果补丁清单里未找到资源包会抛出异常!
|
||||||
var patchBundle = ActivePatchManifest.GetMainPatchBundle(assetInfo.AssetPath);
|
var patchBundle = _activePatchManifest.GetMainPatchBundle(assetInfo.AssetPath);
|
||||||
return CreateBundleInfo(patchBundle);
|
return CreateBundleInfo(patchBundle);
|
||||||
}
|
}
|
||||||
BundleInfo[] IBundleServices.GetAllDependBundleInfos(AssetInfo assetInfo)
|
BundleInfo[] IBundleServices.GetAllDependBundleInfos(AssetInfo assetInfo)
|
||||||
|
@ -360,7 +324,7 @@ namespace YooAsset
|
||||||
throw new Exception("Should never get here !");
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
// 注意:如果补丁清单里未找到资源包会抛出异常!
|
// 注意:如果补丁清单里未找到资源包会抛出异常!
|
||||||
var depends = ActivePatchManifest.GetAllDependencies(assetInfo.AssetPath);
|
var depends = _activePatchManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||||
List<BundleInfo> result = new List<BundleInfo>(depends.Length);
|
List<BundleInfo> result = new List<BundleInfo>(depends.Length);
|
||||||
foreach (var patchBundle in depends)
|
foreach (var patchBundle in depends)
|
||||||
{
|
{
|
||||||
|
@ -371,34 +335,34 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
AssetInfo[] IBundleServices.GetAssetInfos(string[] tags)
|
AssetInfo[] IBundleServices.GetAssetInfos(string[] tags)
|
||||||
{
|
{
|
||||||
return ActivePatchManifest.GetAssetsInfoByTags(tags);
|
return _activePatchManifest.GetAssetsInfoByTags(tags);
|
||||||
}
|
}
|
||||||
PatchAsset IBundleServices.TryGetPatchAsset(string assetPath)
|
PatchAsset IBundleServices.TryGetPatchAsset(string assetPath)
|
||||||
{
|
{
|
||||||
if (ActivePatchManifest.TryGetPatchAsset(assetPath, out PatchAsset patchAsset))
|
if (_activePatchManifest.TryGetPatchAsset(assetPath, out PatchAsset patchAsset))
|
||||||
return patchAsset;
|
return patchAsset;
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
string IBundleServices.MappingToAssetPath(string location)
|
string IBundleServices.MappingToAssetPath(string location)
|
||||||
{
|
{
|
||||||
return ActivePatchManifest.MappingToAssetPath(location);
|
return _activePatchManifest.MappingToAssetPath(location);
|
||||||
}
|
}
|
||||||
string IBundleServices.TryMappingToAssetPath(string location)
|
string IBundleServices.TryMappingToAssetPath(string location)
|
||||||
{
|
{
|
||||||
return ActivePatchManifest.TryMappingToAssetPath(location);
|
return _activePatchManifest.TryMappingToAssetPath(location);
|
||||||
}
|
}
|
||||||
string IBundleServices.GetPackageName()
|
string IBundleServices.GetPackageName()
|
||||||
{
|
{
|
||||||
return ActivePatchManifest.PackageName;
|
return _packageName;
|
||||||
}
|
}
|
||||||
bool IBundleServices.IsIncludeBundleFile(string fileName)
|
bool IBundleServices.IsIncludeBundleFile(string fileName)
|
||||||
{
|
{
|
||||||
return ActivePatchManifest.IsIncludeBundleFile(fileName);
|
return _activePatchManifest.IsIncludeBundleFile(fileName);
|
||||||
}
|
}
|
||||||
bool IBundleServices.IsServicesValid()
|
bool IBundleServices.IsServicesValid()
|
||||||
{
|
{
|
||||||
return ActivePatchManifest != null;
|
return _activePatchManifest != null;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,41 +1,101 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
internal class OfflinePlayModeImpl : IBundleServices
|
internal class OfflinePlayModeImpl : IPlayModeServices, IBundleServices
|
||||||
{
|
{
|
||||||
public PatchManifest ActivePatchManifest { private set; get; }
|
private PatchManifest _activePatchManifest;
|
||||||
|
private string _packageName;
|
||||||
private bool _locationToLower;
|
private bool _locationToLower;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步初始化
|
/// 异步初始化
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public InitializationOperation InitializeAsync(bool locationToLower, string packageName)
|
public InitializationOperation InitializeAsync(string packageName, bool locationToLower)
|
||||||
{
|
{
|
||||||
|
_packageName = packageName;
|
||||||
_locationToLower = locationToLower;
|
_locationToLower = locationToLower;
|
||||||
var operation = new OfflinePlayModeInitializationOperation(this, packageName);
|
var operation = new OfflinePlayModeInitializationOperation(this, packageName);
|
||||||
OperationSystem.StartOperation(operation);
|
OperationSystem.StartOperation(operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
#region IPlayModeServices接口
|
||||||
/// 获取包裹的版本信息
|
public PatchManifest ActivePatchManifest
|
||||||
/// </summary>
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_activePatchManifest = value;
|
||||||
|
_activePatchManifest.InitAssetPathMapping(_locationToLower);
|
||||||
|
}
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _activePatchManifest;
|
||||||
|
}
|
||||||
|
}
|
||||||
public string GetPackageVersion()
|
public string GetPackageVersion()
|
||||||
{
|
{
|
||||||
if (ActivePatchManifest == null)
|
if (_activePatchManifest == null)
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
return ActivePatchManifest.PackageVersion;
|
return _activePatchManifest.PackageVersion;
|
||||||
|
}
|
||||||
|
public bool IsBuildinPatchBundle(PatchBundle patchBundle)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void SetActivePatchManifest(PatchManifest patchManifest)
|
UpdatePackageVersionOperation IPlayModeServices.UpdatePackageVersionAsync(bool appendTimeTicks, int timeout)
|
||||||
{
|
{
|
||||||
ActivePatchManifest = patchManifest;
|
var operation = new OfflinePlayModeUpdatePackageVersionOperation();
|
||||||
ActivePatchManifest.InitAssetPathMapping(_locationToLower);
|
OperationSystem.StartOperation(operation);
|
||||||
|
return operation;
|
||||||
}
|
}
|
||||||
|
UpdatePackageManifestOperation IPlayModeServices.UpdatePackageManifestAsync(string packageVersion, bool autoSaveManifest, bool autoActiveManifest, int timeout)
|
||||||
|
{
|
||||||
|
var operation = new OfflinePlayModeUpdatePackageManifestOperation();
|
||||||
|
OperationSystem.StartOperation(operation);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
CheckPackageContentsOperation IPlayModeServices.CheckPackageContentsAsync()
|
||||||
|
{
|
||||||
|
var operation = new OfflinePlayModeCheckPackageContentsOperation();
|
||||||
|
OperationSystem.StartOperation(operation);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
|
||||||
|
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||||
|
{
|
||||||
|
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||||
|
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||||
|
{
|
||||||
|
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||||
|
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByPaths(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||||
|
{
|
||||||
|
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||||
|
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout)
|
||||||
|
{
|
||||||
|
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||||
|
var operation = new PatchUnpackerOperation(downloadList, upackingMaxNumber, failedTryAgain, int.MaxValue);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout)
|
||||||
|
{
|
||||||
|
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||||
|
var operation = new PatchUnpackerOperation(downloadList, upackingMaxNumber, failedTryAgain, int.MaxValue);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region IBundleServices接口
|
#region IBundleServices接口
|
||||||
private BundleInfo CreateBundleInfo(PatchBundle patchBundle)
|
private BundleInfo CreateBundleInfo(PatchBundle patchBundle)
|
||||||
|
@ -62,7 +122,7 @@ namespace YooAsset
|
||||||
throw new Exception("Should never get here !");
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
// 注意:如果补丁清单里未找到资源包会抛出异常!
|
// 注意:如果补丁清单里未找到资源包会抛出异常!
|
||||||
var patchBundle = ActivePatchManifest.GetMainPatchBundle(assetInfo.AssetPath);
|
var patchBundle = _activePatchManifest.GetMainPatchBundle(assetInfo.AssetPath);
|
||||||
return CreateBundleInfo(patchBundle);
|
return CreateBundleInfo(patchBundle);
|
||||||
}
|
}
|
||||||
BundleInfo[] IBundleServices.GetAllDependBundleInfos(AssetInfo assetInfo)
|
BundleInfo[] IBundleServices.GetAllDependBundleInfos(AssetInfo assetInfo)
|
||||||
|
@ -71,7 +131,7 @@ namespace YooAsset
|
||||||
throw new Exception("Should never get here !");
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
// 注意:如果补丁清单里未找到资源包会抛出异常!
|
// 注意:如果补丁清单里未找到资源包会抛出异常!
|
||||||
var depends = ActivePatchManifest.GetAllDependencies(assetInfo.AssetPath);
|
var depends = _activePatchManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||||
List<BundleInfo> result = new List<BundleInfo>(depends.Length);
|
List<BundleInfo> result = new List<BundleInfo>(depends.Length);
|
||||||
foreach (var patchBundle in depends)
|
foreach (var patchBundle in depends)
|
||||||
{
|
{
|
||||||
|
@ -82,34 +142,34 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
AssetInfo[] IBundleServices.GetAssetInfos(string[] tags)
|
AssetInfo[] IBundleServices.GetAssetInfos(string[] tags)
|
||||||
{
|
{
|
||||||
return ActivePatchManifest.GetAssetsInfoByTags(tags);
|
return _activePatchManifest.GetAssetsInfoByTags(tags);
|
||||||
}
|
}
|
||||||
PatchAsset IBundleServices.TryGetPatchAsset(string assetPath)
|
PatchAsset IBundleServices.TryGetPatchAsset(string assetPath)
|
||||||
{
|
{
|
||||||
if (ActivePatchManifest.TryGetPatchAsset(assetPath, out PatchAsset patchAsset))
|
if (_activePatchManifest.TryGetPatchAsset(assetPath, out PatchAsset patchAsset))
|
||||||
return patchAsset;
|
return patchAsset;
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
string IBundleServices.MappingToAssetPath(string location)
|
string IBundleServices.MappingToAssetPath(string location)
|
||||||
{
|
{
|
||||||
return ActivePatchManifest.MappingToAssetPath(location);
|
return _activePatchManifest.MappingToAssetPath(location);
|
||||||
}
|
}
|
||||||
string IBundleServices.TryMappingToAssetPath(string location)
|
string IBundleServices.TryMappingToAssetPath(string location)
|
||||||
{
|
{
|
||||||
return ActivePatchManifest.TryMappingToAssetPath(location);
|
return _activePatchManifest.TryMappingToAssetPath(location);
|
||||||
}
|
}
|
||||||
string IBundleServices.GetPackageName()
|
string IBundleServices.GetPackageName()
|
||||||
{
|
{
|
||||||
return ActivePatchManifest.PackageName;
|
return _packageName;
|
||||||
}
|
}
|
||||||
bool IBundleServices.IsIncludeBundleFile(string fileName)
|
bool IBundleServices.IsIncludeBundleFile(string fileName)
|
||||||
{
|
{
|
||||||
return ActivePatchManifest.IsIncludeBundleFile(fileName);
|
return _activePatchManifest.IsIncludeBundleFile(fileName);
|
||||||
}
|
}
|
||||||
bool IBundleServices.IsServicesValid()
|
bool IBundleServices.IsServicesValid()
|
||||||
{
|
{
|
||||||
return ActivePatchManifest != null;
|
return _activePatchManifest != null;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
internal interface IPlayModeServices
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 激活的清单
|
||||||
|
/// </summary>
|
||||||
|
PatchManifest ActivePatchManifest { set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取激活包裹的版本信息
|
||||||
|
/// </summary>
|
||||||
|
string GetPackageVersion();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否为内置资源文件
|
||||||
|
/// </summary>
|
||||||
|
bool IsBuildinPatchBundle(PatchBundle patchBundle);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 向网络端请求最新的资源版本
|
||||||
|
/// </summary>
|
||||||
|
UpdatePackageVersionOperation UpdatePackageVersionAsync(bool appendTimeTicks, int timeout);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 向网络端请求并更新补丁清单
|
||||||
|
/// </summary>
|
||||||
|
UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, bool autoSaveManifest, bool autoActiveManifest, int timeout);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 检查本地包裹内容的完整性
|
||||||
|
/// </summary>
|
||||||
|
CheckPackageContentsOperation CheckPackageContentsAsync();
|
||||||
|
|
||||||
|
// 下载相关方法
|
||||||
|
PatchDownloaderOperation CreatePatchDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout);
|
||||||
|
PatchDownloaderOperation CreatePatchDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout);
|
||||||
|
PatchDownloaderOperation CreatePatchDownloaderByPaths(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout);
|
||||||
|
|
||||||
|
// 解压相关方法
|
||||||
|
PatchUnpackerOperation CreatePatchUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout);
|
||||||
|
PatchUnpackerOperation CreatePatchUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4629f36c31a96214b9057827c6a283cf
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -383,19 +383,6 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 包裹更新
|
|
||||||
/// <summary>
|
|
||||||
/// 资源包裹更新,用于下载更新指定资源版本所有的资源包文件
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="packageVersion">指定更新的包裹版本</param>
|
|
||||||
/// <param name="timeout">超时时间</param>
|
|
||||||
public static DownloadPackageOperation DownloadPackageAsync(string packageVersion, int timeout = 60)
|
|
||||||
{
|
|
||||||
DebugCheckDefaultPackageValid();
|
|
||||||
return _defaultPackage.DownloadPackageAsync(packageVersion, timeout);
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region 调试方法
|
#region 调试方法
|
||||||
[Conditional("DEBUG")]
|
[Conditional("DEBUG")]
|
||||||
private static void DebugCheckDefaultPackageValid()
|
private static void DebugCheckDefaultPackageValid()
|
||||||
|
|
Loading…
Reference in New Issue