Compare commits

..

No commits in common. "cb2cb4e556be2342aa3b02ecfd3417cf5ed33fcf" and "191fbff768d190dec00c62201408485fcfe4394a" have entirely different histories.

9 changed files with 25 additions and 171 deletions

View File

@ -15,8 +15,7 @@ namespace YooAsset
CheckDownload, CheckDownload,
Unpack, Unpack,
CheckUnpack, CheckUnpack,
LoadBundleFile, LoadFile,
LoadDeliveryFile,
CheckLoadFile, CheckLoadFile,
Done, Done,
} }
@ -60,22 +59,22 @@ namespace YooAsset
} }
else else
{ {
_steps = ESteps.LoadBundleFile; _steps = ESteps.LoadFile;
FileLoadPath = MainBundleInfo.Bundle.StreamingFilePath; FileLoadPath = MainBundleInfo.Bundle.StreamingFilePath;
} }
#else #else
_steps = ESteps.LoadBundleFile; _steps = ESteps.LoadFile;
FileLoadPath = MainBundleInfo.Bundle.StreamingFilePath; FileLoadPath = MainBundleInfo.Bundle.StreamingFilePath;
#endif #endif
} }
else if (MainBundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromCache) else if (MainBundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromCache)
{ {
_steps = ESteps.LoadBundleFile; _steps = ESteps.LoadFile;
FileLoadPath = MainBundleInfo.Bundle.CachedDataFilePath; FileLoadPath = MainBundleInfo.Bundle.CachedDataFilePath;
} }
else if (MainBundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromDelivery) else if (MainBundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromDelivery)
{ {
_steps = ESteps.LoadDeliveryFile; _steps = ESteps.LoadFile;
FileLoadPath = MainBundleInfo.DeliveryFilePath; FileLoadPath = MainBundleInfo.DeliveryFilePath;
} }
else else
@ -109,7 +108,7 @@ namespace YooAsset
} }
else else
{ {
_steps = ESteps.LoadBundleFile; _steps = ESteps.LoadFile;
return; //下载完毕等待一帧再去加载! return; //下载完毕等待一帧再去加载!
} }
} }
@ -140,12 +139,12 @@ namespace YooAsset
} }
else else
{ {
_steps = ESteps.LoadBundleFile; _steps = ESteps.LoadFile;
} }
} }
// 5. 加载AssetBundle // 5. 加载AssetBundle
if (_steps == ESteps.LoadBundleFile) if (_steps == ESteps.LoadFile)
{ {
#if UNITY_EDITOR #if UNITY_EDITOR
// 注意Unity2017.4编辑器模式下如果AssetBundle文件不存在会导致编辑器崩溃这里做了预判。 // 注意Unity2017.4编辑器模式下如果AssetBundle文件不存在会导致编辑器崩溃这里做了预判。
@ -220,35 +219,7 @@ namespace YooAsset
_steps = ESteps.CheckLoadFile; _steps = ESteps.CheckLoadFile;
} }
// 6. 加载AssetBundle // 6. 检测AssetBundle加载结果
if (_steps == ESteps.LoadDeliveryFile)
{
// 设置下载进度
DownloadProgress = 1f;
DownloadedBytes = (ulong)MainBundleInfo.Bundle.FileSize;
// Load assetBundle file
var loadMethod = (EBundleLoadMethod)MainBundleInfo.Bundle.LoadMethod;
if (loadMethod == EBundleLoadMethod.Normal)
{
ulong offset = MainBundleInfo.DeliveryFileOffset;
if (_isWaitForAsyncComplete)
CacheBundle = AssetBundle.LoadFromFile(FileLoadPath, 0, offset);
else
_createRequest = AssetBundle.LoadFromFileAsync(FileLoadPath, 0, offset);
}
else
{
_steps = ESteps.Done;
Status = EStatus.Failed;
LastError = $"Delivery file not support encryption : {MainBundleInfo.Bundle.BundleName}";
YooLogger.Error(LastError);
return;
}
_steps = ESteps.CheckLoadFile;
}
// 7. 检测AssetBundle加载结果
if (_steps == ESteps.CheckLoadFile) if (_steps == ESteps.CheckLoadFile)
{ {
if (_createRequest != null) if (_createRequest != null)

View File

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

View File

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

View File

@ -571,18 +571,6 @@ namespace YooAsset
return LoadAssetInternal(assetInfo, true); return LoadAssetInternal(assetInfo, true);
} }
/// <summary>
/// 同步加载资源对象
/// </summary>
/// <param name="location">资源的定位地址</param>
public AssetOperationHandle LoadAssetSync(string location)
{
DebugCheckInitialize();
Type type = typeof(UnityEngine.Object);
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
return LoadAssetInternal(assetInfo, true);
}
/// <summary> /// <summary>
/// 异步加载资源对象 /// 异步加载资源对象
@ -618,18 +606,6 @@ namespace YooAsset
return LoadAssetInternal(assetInfo, false); return LoadAssetInternal(assetInfo, false);
} }
/// <summary>
/// 异步加载资源对象
/// </summary>
/// <param name="location">资源的定位地址</param>
public AssetOperationHandle LoadAssetAsync(string location)
{
DebugCheckInitialize();
Type type = typeof(UnityEngine.Object);
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
return LoadAssetInternal(assetInfo, false);
}
private AssetOperationHandle LoadAssetInternal(AssetInfo assetInfo, bool waitForAsyncComplete) private AssetOperationHandle LoadAssetInternal(AssetInfo assetInfo, bool waitForAsyncComplete)
{ {
@ -684,18 +660,6 @@ namespace YooAsset
return LoadSubAssetsInternal(assetInfo, true); return LoadSubAssetsInternal(assetInfo, true);
} }
/// <summary>
/// 同步加载子资源对象
/// </summary>
/// <param name="location">资源的定位地址</param>
public SubAssetsOperationHandle LoadSubAssetsSync(string location)
{
DebugCheckInitialize();
Type type = typeof(UnityEngine.Object);
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
return LoadSubAssetsInternal(assetInfo, true);
}
/// <summary> /// <summary>
/// 异步加载子资源对象 /// 异步加载子资源对象
@ -731,18 +695,6 @@ namespace YooAsset
return LoadSubAssetsInternal(assetInfo, false); return LoadSubAssetsInternal(assetInfo, false);
} }
/// <summary>
/// 异步加载子资源对象
/// </summary>
/// <param name="location">资源的定位地址</param>
public SubAssetsOperationHandle LoadSubAssetsAsync(string location)
{
DebugCheckInitialize();
Type type = typeof(UnityEngine.Object);
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
return LoadSubAssetsInternal(assetInfo, false);
}
private SubAssetsOperationHandle LoadSubAssetsInternal(AssetInfo assetInfo, bool waitForAsyncComplete) private SubAssetsOperationHandle LoadSubAssetsInternal(AssetInfo assetInfo, bool waitForAsyncComplete)
{ {
@ -797,18 +749,6 @@ namespace YooAsset
return LoadAllAssetsInternal(assetInfo, true); return LoadAllAssetsInternal(assetInfo, true);
} }
/// <summary>
/// 同步加载资源包内所有资源对象
/// </summary>
/// <param name="location">资源的定位地址</param>
public AllAssetsOperationHandle LoadAllAssetsSync(string location)
{
DebugCheckInitialize();
Type type = typeof(UnityEngine.Object);
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
return LoadAllAssetsInternal(assetInfo, true);
}
/// <summary> /// <summary>
/// 异步加载资源包内所有资源对象 /// 异步加载资源包内所有资源对象
@ -844,18 +784,6 @@ namespace YooAsset
return LoadAllAssetsInternal(assetInfo, false); return LoadAllAssetsInternal(assetInfo, false);
} }
/// <summary>
/// 异步加载资源包内所有资源对象
/// </summary>
/// <param name="location">资源的定位地址</param>
public AllAssetsOperationHandle LoadAllAssetsAsync(string location)
{
DebugCheckInitialize();
Type type = typeof(UnityEngine.Object);
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
return LoadAllAssetsInternal(assetInfo, false);
}
private AllAssetsOperationHandle LoadAllAssetsInternal(AssetInfo assetInfo, bool waitForAsyncComplete) private AllAssetsOperationHandle LoadAllAssetsInternal(AssetInfo assetInfo, bool waitForAsyncComplete)
{ {

View File

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

View File

@ -8,14 +8,9 @@ using YooAsset;
/// </summary> /// </summary>
public class GameQueryServices : IQueryServices public class GameQueryServices : IQueryServices
{ {
public DeliveryFileInfo GetDeliveryFileInfo(string packageName, string fileName) public string QueryDeliveryFiles(string packageName, string fileName)
{ {
throw new System.NotImplementedException(); return null;
}
public bool QueryDeliveryFiles(string packageName, string fileName)
{
return false;
} }
public bool QueryStreamingAssets(string packageName, string fileName) public bool QueryStreamingAssets(string packageName, string fileName)

View File

@ -11,14 +11,9 @@ using YooAsset;
/// </summary> /// </summary>
public class GameQueryServices2 : IQueryServices public class GameQueryServices2 : IQueryServices
{ {
public DeliveryFileInfo GetDeliveryFileInfo(string packageName, string fileName) public string QueryDeliveryFiles(string packageName, string fileName)
{ {
throw new System.NotImplementedException(); return null;
}
public bool QueryDeliveryFiles(string packageName, string fileName)
{
return false;
} }
public bool QueryStreamingAssets(string packageName, string fileName) public bool QueryStreamingAssets(string packageName, string fileName)