update runtime code

pull/134/head
hevinci 2023-07-20 11:08:28 +08:00
parent 191fbff768
commit b53b6a4246
5 changed files with 47 additions and 12 deletions

View File

@ -31,6 +31,11 @@ namespace YooAsset
/// </summary>
public string DeliveryFilePath { private set; get; }
/// <summary>
/// 开发者分发的文件偏移量
/// </summary>
public ulong DeliveryFileOffset { private set; get; }
/// <summary>
/// 注意:该字段只用于帮助编辑器下的模拟模式。
/// </summary>
@ -47,14 +52,16 @@ namespace YooAsset
RemoteMainURL = mainURL;
RemoteFallbackURL = fallbackURL;
DeliveryFilePath = string.Empty;
DeliveryFileOffset = 0;
}
public BundleInfo(PackageBundle bundle, ELoadMode loadMode, string deliveryFilePath)
public BundleInfo(PackageBundle bundle, ELoadMode loadMode, string deliveryFilePath, ulong deliveryFileOffset)
{
Bundle = bundle;
LoadMode = loadMode;
RemoteMainURL = string.Empty;
RemoteFallbackURL = string.Empty;
DeliveryFilePath = deliveryFilePath;
DeliveryFileOffset = deliveryFileOffset;
}
public BundleInfo(PackageBundle bundle, ELoadMode loadMode)
{
@ -63,6 +70,7 @@ namespace YooAsset
RemoteMainURL = string.Empty;
RemoteFallbackURL = string.Empty;
DeliveryFilePath = string.Empty;
DeliveryFileOffset = 0;
}
/// <summary>

View File

@ -60,13 +60,13 @@ namespace YooAsset
{
return CacheSystem.IsCached(packageBundle.PackageName, packageBundle.CacheGUID);
}
private bool IsDeliveryPackageBundle(PackageBundle packageBundle, out string deliveryFilePath)
private bool IsDeliveryPackageBundle(PackageBundle packageBundle)
{
deliveryFilePath = _queryServices.QueryDeliveryFiles(_packageName, packageBundle.FileName);
if (string.IsNullOrEmpty(deliveryFilePath))
return false;
else
return true;
return _queryServices.QueryDeliveryFiles(_packageName, packageBundle.FileName);
}
private DeliveryFileInfo GetDeiveryFileInfo(PackageBundle packageBundle)
{
return _queryServices.GetDeliveryFileInfo(_packageName, packageBundle.FileName);
}
#region IPlayModeServices接口
@ -119,6 +119,10 @@ namespace YooAsset
List<PackageBundle> downloadList = new List<PackageBundle>(1000);
foreach (var packageBundle in manifest.BundleList)
{
// 忽略分发文件
if (IsDeliveryPackageBundle(packageBundle))
continue;
// 忽略缓存文件
if (IsCachedPackageBundle(packageBundle))
continue;
@ -144,6 +148,10 @@ namespace YooAsset
List<PackageBundle> downloadList = new List<PackageBundle>(1000);
foreach (var packageBundle in manifest.BundleList)
{
// 忽略分发文件
if (IsDeliveryPackageBundle(packageBundle))
continue;
// 忽略缓存文件
if (IsCachedPackageBundle(packageBundle))
continue;
@ -205,6 +213,10 @@ namespace YooAsset
List<PackageBundle> downloadList = new List<PackageBundle>(1000);
foreach (var packageBundle in checkList)
{
// 忽略分发文件
if (IsDeliveryPackageBundle(packageBundle))
continue;
// 忽略缓存文件
if (IsCachedPackageBundle(packageBundle))
continue;
@ -279,9 +291,10 @@ namespace YooAsset
throw new Exception("Should never get here !");
// 查询分发资源
if (IsDeliveryPackageBundle(packageBundle, out string deliveryFilePath))
if (IsDeliveryPackageBundle(packageBundle))
{
BundleInfo bundleInfo = new BundleInfo(packageBundle, BundleInfo.ELoadMode.LoadFromDelivery, deliveryFilePath);
DeliveryFileInfo deliveryFileInfo = GetDeiveryFileInfo(packageBundle);
BundleInfo bundleInfo = new BundleInfo(packageBundle, BundleInfo.ELoadMode.LoadFromDelivery, deliveryFileInfo.DeliveryFilePath, deliveryFileInfo.DeliveryFileOffset);
return bundleInfo;
}

View File

@ -1,6 +1,15 @@

namespace YooAsset
{
/// <summary>
/// 分发的资源信息
/// </summary>
public struct DeliveryFileInfo
{
public string DeliveryFilePath;
public ulong DeliveryFileOffset;
}
public interface IQueryServices
{
/// <summary>
@ -9,8 +18,13 @@ namespace YooAsset
bool QueryStreamingAssets(string packageName, string fileName);
/// <summary>
/// 查询开发者分发的文件加载路径
/// 查询是否为开发者分发的资源
/// </summary>
string QueryDeliveryFiles(string packageName, string fileName);
bool QueryDeliveryFiles(string packageName, string fileName);
/// <summary>
/// 获取开发者分发的资源信息
/// </summary>
DeliveryFileInfo GetDeliveryFileInfo(string packageName, string fileName);
}
}