update runtime code

支持开发者资源分发和加载
pull/134/head
hevinci 2023-07-19 17:06:20 +08:00
parent b5df539392
commit b737b20602
4 changed files with 42 additions and 1 deletions

View File

@ -72,6 +72,11 @@ namespace YooAsset
_steps = ESteps.LoadFile;
FileLoadPath = MainBundleInfo.Bundle.CachedDataFilePath;
}
else if (MainBundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromDelivery)
{
_steps = ESteps.LoadFile;
FileLoadPath = MainBundleInfo.DeliveryFilePath;
}
else
{
throw new System.NotImplementedException(MainBundleInfo.LoadMode.ToString());

View File

@ -6,6 +6,7 @@ namespace YooAsset
public enum ELoadMode
{
None,
LoadFromDelivery,
LoadFromStreaming,
LoadFromCache,
LoadFromRemote,
@ -25,6 +26,11 @@ namespace YooAsset
/// </summary>
public string RemoteFallbackURL { private set; get; }
/// <summary>
/// 开发者分发的文件地址
/// </summary>
public string DeliveryFilePath { private set; get; }
/// <summary>
/// 注意:该字段只用于帮助编辑器下的模拟模式。
/// </summary>
@ -40,6 +46,15 @@ namespace YooAsset
LoadMode = loadMode;
RemoteMainURL = mainURL;
RemoteFallbackURL = fallbackURL;
DeliveryFilePath = string.Empty;
}
public BundleInfo(PackageBundle bundle, ELoadMode loadMode, string deliveryFilePath)
{
Bundle = bundle;
LoadMode = loadMode;
RemoteMainURL = string.Empty;
RemoteFallbackURL = string.Empty;
DeliveryFilePath = deliveryFilePath;
}
public BundleInfo(PackageBundle bundle, ELoadMode loadMode)
{
@ -47,6 +62,7 @@ namespace YooAsset
LoadMode = loadMode;
RemoteMainURL = string.Empty;
RemoteFallbackURL = string.Empty;
DeliveryFilePath = string.Empty;
}
/// <summary>

View File

@ -60,6 +60,14 @@ namespace YooAsset
{
return CacheSystem.IsCached(packageBundle.PackageName, packageBundle.CacheGUID);
}
private bool IsDeliveryPackageBundle(PackageBundle packageBundle, out string deliveryFilePath)
{
deliveryFilePath = _queryServices.QueryDeliveryFiles(_packageName, packageBundle.FileName);
if (string.IsNullOrEmpty(deliveryFilePath))
return false;
else
return true;
}
#region IPlayModeServices接口
public PackageManifest ActiveManifest
@ -270,6 +278,13 @@ namespace YooAsset
if (packageBundle == null)
throw new Exception("Should never get here !");
// 查询分发资源
if (IsDeliveryPackageBundle(packageBundle, out string deliveryFilePath))
{
BundleInfo bundleInfo = new BundleInfo(packageBundle, BundleInfo.ELoadMode.LoadFromDelivery, deliveryFilePath);
return bundleInfo;
}
// 查询沙盒资源
if (IsCachedPackageBundle(packageBundle))
{

View File

@ -4,8 +4,13 @@ namespace YooAsset
public interface IQueryServices
{
/// <summary>
/// 查询内置资源
/// 查询应用程序里的内置资源是否存在
/// </summary>
bool QueryStreamingAssets(string packageName, string fileName);
/// <summary>
/// 查询开发者分发的文件加载路径
/// </summary>
string QueryDeliveryFiles(string packageName, string fileName);
}
}