update package system

离线模式支持内置资源解压到沙盒
pull/122/head
hevinci 2023-06-26 10:25:12 +08:00
parent 14ee95615f
commit b98d4cb091
1 changed files with 60 additions and 2 deletions

View File

@ -20,6 +20,22 @@ namespace YooAsset
return operation; return operation;
} }
// 解压相关
private List<BundleInfo> ConvertToUnpackList(List<PackageBundle> unpackList)
{
List<BundleInfo> result = new List<BundleInfo>(unpackList.Count);
foreach (var packageBundle in unpackList)
{
var bundleInfo = ConvertToUnpackInfo(packageBundle);
result.Add(bundleInfo);
}
return result;
}
private BundleInfo ConvertToUnpackInfo(PackageBundle packageBundle)
{
return ManifestTools.GetUnpackInfo(packageBundle);
}
#region IPlayModeServices接口 #region IPlayModeServices接口
public PackageManifest ActiveManifest public PackageManifest ActiveManifest
{ {
@ -37,6 +53,11 @@ namespace YooAsset
{ {
} }
private bool IsCachedPackageBundle(PackageBundle packageBundle)
{
return CacheSystem.IsCached(packageBundle.PackageName, packageBundle.CacheGUID);
}
UpdatePackageVersionOperation IPlayModeServices.UpdatePackageVersionAsync(bool appendTimeTicks, int timeout) UpdatePackageVersionOperation IPlayModeServices.UpdatePackageVersionAsync(bool appendTimeTicks, int timeout)
{ {
var operation = new OfflinePlayModeUpdatePackageVersionOperation(); var operation = new OfflinePlayModeUpdatePackageVersionOperation();
@ -71,11 +92,48 @@ namespace YooAsset
ResourceUnpackerOperation IPlayModeServices.CreateResourceUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout) ResourceUnpackerOperation IPlayModeServices.CreateResourceUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout)
{ {
return ResourceUnpackerOperation.CreateEmptyUnpacker(upackingMaxNumber, failedTryAgain, timeout); List<BundleInfo> unpcakList = GetUnpackListByAll(_activeManifest);
var operation = new ResourceUnpackerOperation(unpcakList, upackingMaxNumber, failedTryAgain, timeout);
return operation;
} }
private List<BundleInfo> GetUnpackListByAll(PackageManifest manifest)
{
List<PackageBundle> downloadList = new List<PackageBundle>(1000);
foreach (var packageBundle in manifest.BundleList)
{
// 忽略缓存文件
if (IsCachedPackageBundle(packageBundle))
continue;
downloadList.Add(packageBundle);
}
return ConvertToUnpackList(downloadList);
}
ResourceUnpackerOperation IPlayModeServices.CreateResourceUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout) ResourceUnpackerOperation IPlayModeServices.CreateResourceUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout)
{ {
return ResourceUnpackerOperation.CreateEmptyUnpacker(upackingMaxNumber, failedTryAgain, timeout); List<BundleInfo> unpcakList = GetUnpackListByTags(_activeManifest, tags);
var operation = new ResourceUnpackerOperation(unpcakList, upackingMaxNumber, failedTryAgain, timeout);
return operation;
}
private List<BundleInfo> GetUnpackListByTags(PackageManifest manifest, string[] tags)
{
List<PackageBundle> downloadList = new List<PackageBundle>(1000);
foreach (var packageBundle in manifest.BundleList)
{
// 忽略缓存文件
if (IsCachedPackageBundle(packageBundle))
continue;
// 查询DLC资源
if (packageBundle.HasTag(tags))
{
downloadList.Add(packageBundle);
}
}
return ConvertToUnpackList(downloadList);
} }
#endregion #endregion