mirror of https://github.com/tuyoogame/YooAsset
Compare commits
No commits in common. "cb2cb4e556be2342aa3b02ecfd3417cf5ed33fcf" and "191fbff768d190dec00c62201408485fcfe4394a" have entirely different histories.
cb2cb4e556
...
191fbff768
|
@ -15,8 +15,7 @@ namespace YooAsset
|
|||
CheckDownload,
|
||||
Unpack,
|
||||
CheckUnpack,
|
||||
LoadBundleFile,
|
||||
LoadDeliveryFile,
|
||||
LoadFile,
|
||||
CheckLoadFile,
|
||||
Done,
|
||||
}
|
||||
|
@ -60,22 +59,22 @@ namespace YooAsset
|
|||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.LoadBundleFile;
|
||||
_steps = ESteps.LoadFile;
|
||||
FileLoadPath = MainBundleInfo.Bundle.StreamingFilePath;
|
||||
}
|
||||
#else
|
||||
_steps = ESteps.LoadBundleFile;
|
||||
_steps = ESteps.LoadFile;
|
||||
FileLoadPath = MainBundleInfo.Bundle.StreamingFilePath;
|
||||
#endif
|
||||
}
|
||||
else if (MainBundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromCache)
|
||||
{
|
||||
_steps = ESteps.LoadBundleFile;
|
||||
_steps = ESteps.LoadFile;
|
||||
FileLoadPath = MainBundleInfo.Bundle.CachedDataFilePath;
|
||||
}
|
||||
else if (MainBundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromDelivery)
|
||||
{
|
||||
_steps = ESteps.LoadDeliveryFile;
|
||||
_steps = ESteps.LoadFile;
|
||||
FileLoadPath = MainBundleInfo.DeliveryFilePath;
|
||||
}
|
||||
else
|
||||
|
@ -109,7 +108,7 @@ namespace YooAsset
|
|||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.LoadBundleFile;
|
||||
_steps = ESteps.LoadFile;
|
||||
return; //下载完毕等待一帧再去加载!
|
||||
}
|
||||
}
|
||||
|
@ -140,12 +139,12 @@ namespace YooAsset
|
|||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.LoadBundleFile;
|
||||
_steps = ESteps.LoadFile;
|
||||
}
|
||||
}
|
||||
|
||||
// 5. 加载AssetBundle
|
||||
if (_steps == ESteps.LoadBundleFile)
|
||||
if (_steps == ESteps.LoadFile)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
// 注意:Unity2017.4编辑器模式下,如果AssetBundle文件不存在会导致编辑器崩溃,这里做了预判。
|
||||
|
@ -220,35 +219,7 @@ namespace YooAsset
|
|||
_steps = ESteps.CheckLoadFile;
|
||||
}
|
||||
|
||||
// 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加载结果
|
||||
// 6. 检测AssetBundle加载结果
|
||||
if (_steps == ESteps.CheckLoadFile)
|
||||
{
|
||||
if (_createRequest != null)
|
||||
|
|
|
@ -30,12 +30,7 @@ namespace YooAsset
|
|||
/// 开发者分发的文件地址
|
||||
/// </summary>
|
||||
public string DeliveryFilePath { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 开发者分发的文件偏移量
|
||||
/// </summary>
|
||||
public ulong DeliveryFileOffset { private set; get; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 注意:该字段只用于帮助编辑器下的模拟模式。
|
||||
/// </summary>
|
||||
|
@ -52,16 +47,14 @@ namespace YooAsset
|
|||
RemoteMainURL = mainURL;
|
||||
RemoteFallbackURL = fallbackURL;
|
||||
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;
|
||||
LoadMode = loadMode;
|
||||
RemoteMainURL = string.Empty;
|
||||
RemoteFallbackURL = string.Empty;
|
||||
DeliveryFilePath = deliveryFilePath;
|
||||
DeliveryFileOffset = deliveryFileOffset;
|
||||
}
|
||||
public BundleInfo(PackageBundle bundle, ELoadMode loadMode)
|
||||
{
|
||||
|
@ -70,7 +63,6 @@ namespace YooAsset
|
|||
RemoteMainURL = string.Empty;
|
||||
RemoteFallbackURL = string.Empty;
|
||||
DeliveryFilePath = string.Empty;
|
||||
DeliveryFileOffset = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -60,13 +60,13 @@ namespace YooAsset
|
|||
{
|
||||
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);
|
||||
}
|
||||
private DeliveryFileInfo GetDeiveryFileInfo(PackageBundle packageBundle)
|
||||
{
|
||||
return _queryServices.GetDeliveryFileInfo(_packageName, packageBundle.FileName);
|
||||
deliveryFilePath = _queryServices.QueryDeliveryFiles(_packageName, packageBundle.FileName);
|
||||
if (string.IsNullOrEmpty(deliveryFilePath))
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
#region IPlayModeServices接口
|
||||
|
@ -119,10 +119,6 @@ namespace YooAsset
|
|||
List<PackageBundle> downloadList = new List<PackageBundle>(1000);
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
// 忽略分发文件
|
||||
if (IsDeliveryPackageBundle(packageBundle))
|
||||
continue;
|
||||
|
||||
// 忽略缓存文件
|
||||
if (IsCachedPackageBundle(packageBundle))
|
||||
continue;
|
||||
|
@ -148,10 +144,6 @@ namespace YooAsset
|
|||
List<PackageBundle> downloadList = new List<PackageBundle>(1000);
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
// 忽略分发文件
|
||||
if (IsDeliveryPackageBundle(packageBundle))
|
||||
continue;
|
||||
|
||||
// 忽略缓存文件
|
||||
if (IsCachedPackageBundle(packageBundle))
|
||||
continue;
|
||||
|
@ -213,10 +205,6 @@ namespace YooAsset
|
|||
List<PackageBundle> downloadList = new List<PackageBundle>(1000);
|
||||
foreach (var packageBundle in checkList)
|
||||
{
|
||||
// 忽略分发文件
|
||||
if (IsDeliveryPackageBundle(packageBundle))
|
||||
continue;
|
||||
|
||||
// 忽略缓存文件
|
||||
if (IsCachedPackageBundle(packageBundle))
|
||||
continue;
|
||||
|
@ -291,10 +279,9 @@ namespace YooAsset
|
|||
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, deliveryFileInfo.DeliveryFilePath, deliveryFileInfo.DeliveryFileOffset);
|
||||
BundleInfo bundleInfo = new BundleInfo(packageBundle, BundleInfo.ELoadMode.LoadFromDelivery, deliveryFilePath);
|
||||
return bundleInfo;
|
||||
}
|
||||
|
||||
|
|
|
@ -571,18 +571,6 @@ namespace YooAsset
|
|||
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>
|
||||
/// 异步加载资源对象
|
||||
|
@ -618,18 +606,6 @@ namespace YooAsset
|
|||
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)
|
||||
{
|
||||
|
@ -684,18 +660,6 @@ namespace YooAsset
|
|||
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>
|
||||
/// 异步加载子资源对象
|
||||
|
@ -731,18 +695,6 @@ namespace YooAsset
|
|||
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)
|
||||
{
|
||||
|
@ -797,18 +749,6 @@ namespace YooAsset
|
|||
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>
|
||||
/// 异步加载资源包内所有资源对象
|
||||
|
@ -844,18 +784,6 @@ namespace YooAsset
|
|||
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)
|
||||
{
|
||||
|
|
|
@ -1,15 +1,6 @@
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
/// <summary>
|
||||
/// 分发的资源信息
|
||||
/// </summary>
|
||||
public struct DeliveryFileInfo
|
||||
{
|
||||
public string DeliveryFilePath;
|
||||
public ulong DeliveryFileOffset;
|
||||
}
|
||||
|
||||
public interface IQueryServices
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -18,13 +9,8 @@ namespace YooAsset
|
|||
bool QueryStreamingAssets(string packageName, string fileName);
|
||||
|
||||
/// <summary>
|
||||
/// 查询是否为开发者分发的资源
|
||||
/// 查询开发者分发的文件加载路径
|
||||
/// </summary>
|
||||
bool QueryDeliveryFiles(string packageName, string fileName);
|
||||
|
||||
/// <summary>
|
||||
/// 获取开发者分发的资源信息
|
||||
/// </summary>
|
||||
DeliveryFileInfo GetDeliveryFileInfo(string packageName, string fileName);
|
||||
string QueryDeliveryFiles(string packageName, string fileName);
|
||||
}
|
||||
}
|
|
@ -8,14 +8,9 @@ using YooAsset;
|
|||
/// </summary>
|
||||
public class GameQueryServices : IQueryServices
|
||||
{
|
||||
public DeliveryFileInfo GetDeliveryFileInfo(string packageName, string fileName)
|
||||
public string QueryDeliveryFiles(string packageName, string fileName)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public bool QueryDeliveryFiles(string packageName, string fileName)
|
||||
{
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool QueryStreamingAssets(string packageName, string fileName)
|
||||
|
|
|
@ -11,14 +11,9 @@ using YooAsset;
|
|||
/// </summary>
|
||||
public class GameQueryServices2 : IQueryServices
|
||||
{
|
||||
public DeliveryFileInfo GetDeliveryFileInfo(string packageName, string fileName)
|
||||
public string QueryDeliveryFiles(string packageName, string fileName)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public bool QueryDeliveryFiles(string packageName, string fileName)
|
||||
{
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool QueryStreamingAssets(string packageName, string fileName)
|
||||
|
|
Loading…
Reference in New Issue