Update YooAssets
parent
050c962587
commit
33ad0713fe
|
@ -227,8 +227,8 @@ namespace YooAsset
|
||||||
|
|
||||||
internal static BundleFileLoader CreateOwnerBundleLoader(string assetPath)
|
internal static BundleFileLoader CreateOwnerBundleLoader(string assetPath)
|
||||||
{
|
{
|
||||||
string bundleName = BundleServices.GetAssetBundleName(assetPath);
|
string bundleName = BundleServices.GetBundleName(assetPath);
|
||||||
AssetBundleInfo bundleInfo = BundleServices.GetAssetBundleInfo(bundleName);
|
BundleInfo bundleInfo = BundleServices.GetBundleInfo(bundleName);
|
||||||
return CreateBundleFileLoaderInternal(bundleInfo);
|
return CreateBundleFileLoaderInternal(bundleInfo);
|
||||||
}
|
}
|
||||||
internal static List<BundleFileLoader> CreateDependBundleLoaders(string assetPath)
|
internal static List<BundleFileLoader> CreateDependBundleLoaders(string assetPath)
|
||||||
|
@ -239,7 +239,7 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
foreach (var dependBundleName in depends)
|
foreach (var dependBundleName in depends)
|
||||||
{
|
{
|
||||||
AssetBundleInfo dependBundleInfo = BundleServices.GetAssetBundleInfo(dependBundleName);
|
BundleInfo dependBundleInfo = BundleServices.GetBundleInfo(dependBundleName);
|
||||||
BundleFileLoader dependLoader = CreateBundleFileLoaderInternal(dependBundleInfo);
|
BundleFileLoader dependLoader = CreateBundleFileLoaderInternal(dependBundleInfo);
|
||||||
result.Add(dependLoader);
|
result.Add(dependLoader);
|
||||||
}
|
}
|
||||||
|
@ -254,7 +254,7 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BundleFileLoader CreateBundleFileLoaderInternal(AssetBundleInfo bundleInfo)
|
private static BundleFileLoader CreateBundleFileLoaderInternal(BundleInfo bundleInfo)
|
||||||
{
|
{
|
||||||
// 如果加载器已经存在
|
// 如果加载器已经存在
|
||||||
BundleFileLoader loader = TryGetBundleFileLoader(bundleInfo.BundleName);
|
BundleFileLoader loader = TryGetBundleFileLoader(bundleInfo.BundleName);
|
||||||
|
@ -272,7 +272,7 @@ namespace YooAsset
|
||||||
for (int i = 0; i < _loaders.Count; i++)
|
for (int i = 0; i < _loaders.Count; i++)
|
||||||
{
|
{
|
||||||
BundleFileLoader temp = _loaders[i];
|
BundleFileLoader temp = _loaders[i];
|
||||||
if (temp.BundleInfo.BundleName.Equals(bundleName))
|
if (temp.BundleFileInfo.BundleName.Equals(bundleName))
|
||||||
{
|
{
|
||||||
loader = temp;
|
loader = temp;
|
||||||
break;
|
break;
|
||||||
|
@ -304,7 +304,7 @@ namespace YooAsset
|
||||||
|
|
||||||
foreach (var provider in _providers)
|
foreach (var provider in _providers)
|
||||||
{
|
{
|
||||||
DebugSummy.ProviderInfo providerInfo = new DebugSummy.ProviderInfo();
|
DebugSummy.DebugProviderInfo providerInfo = new DebugSummy.DebugProviderInfo();
|
||||||
providerInfo.AssetPath = provider.AssetPath;
|
providerInfo.AssetPath = provider.AssetPath;
|
||||||
providerInfo.RefCount = provider.RefCount;
|
providerInfo.RefCount = provider.RefCount;
|
||||||
providerInfo.States = provider.States;
|
providerInfo.States = provider.States;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
public class AssetBundleInfo
|
public class BundleInfo
|
||||||
{
|
{
|
||||||
private readonly PatchBundle _patchBundle;
|
private readonly PatchBundle _patchBundle;
|
||||||
|
|
||||||
|
@ -110,10 +110,10 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private AssetBundleInfo()
|
private BundleInfo()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
internal AssetBundleInfo(PatchBundle patchBundle, string localPath, string mainURL, string fallbackURL)
|
internal BundleInfo(PatchBundle patchBundle, string localPath, string mainURL, string fallbackURL)
|
||||||
{
|
{
|
||||||
_patchBundle = patchBundle;
|
_patchBundle = patchBundle;
|
||||||
BundleName = patchBundle.BundleName;
|
BundleName = patchBundle.BundleName;
|
||||||
|
@ -121,7 +121,7 @@ namespace YooAsset
|
||||||
RemoteMainURL = mainURL;
|
RemoteMainURL = mainURL;
|
||||||
RemoteFallbackURL = fallbackURL;
|
RemoteFallbackURL = fallbackURL;
|
||||||
}
|
}
|
||||||
internal AssetBundleInfo(PatchBundle patchBundle, string localPath)
|
internal BundleInfo(PatchBundle patchBundle, string localPath)
|
||||||
{
|
{
|
||||||
_patchBundle = patchBundle;
|
_patchBundle = patchBundle;
|
||||||
BundleName = patchBundle.BundleName;
|
BundleName = patchBundle.BundleName;
|
||||||
|
@ -129,7 +129,7 @@ namespace YooAsset
|
||||||
RemoteMainURL = string.Empty;
|
RemoteMainURL = string.Empty;
|
||||||
RemoteFallbackURL = string.Empty;
|
RemoteFallbackURL = string.Empty;
|
||||||
}
|
}
|
||||||
internal AssetBundleInfo(string bundleName, string localPath)
|
internal BundleInfo(string bundleName, string localPath)
|
||||||
{
|
{
|
||||||
_patchBundle = null;
|
_patchBundle = null;
|
||||||
BundleName = bundleName;
|
BundleName = bundleName;
|
|
@ -6,12 +6,12 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取AssetBundle的信息
|
/// 获取AssetBundle的信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
AssetBundleInfo GetAssetBundleInfo(string bundleName);
|
BundleInfo GetBundleInfo(string bundleName);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源所属的资源包名称
|
/// 获取资源所属的资源包名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
string GetAssetBundleName(string assetPath);
|
string GetBundleName(string assetPath);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源依赖的所有AssetBundle列表
|
/// 获取资源依赖的所有AssetBundle列表
|
||||||
|
|
|
@ -8,11 +8,11 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取解密的数据偏移
|
/// 获取解密的数据偏移
|
||||||
/// </summary>
|
/// </summary>
|
||||||
ulong GetDecryptOffset(AssetBundleInfo bundleInfo);
|
ulong GetDecryptOffset(BundleInfo bundleInfo);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取解密的字节数据
|
/// 获取解密的字节数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
byte[] GetDecryptBinary(AssetBundleInfo bundleInfo);
|
byte[] GetDecryptBinary(BundleInfo bundleInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -8,9 +8,9 @@ namespace YooAsset
|
||||||
internal class BundleFileLoader
|
internal class BundleFileLoader
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源文件信息
|
/// 资源包文件信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public AssetBundleInfo BundleInfo { private set; get; }
|
public BundleInfo BundleFileInfo { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 引用计数
|
/// 引用计数
|
||||||
|
@ -35,9 +35,9 @@ namespace YooAsset
|
||||||
internal AssetBundle CacheBundle { private set; get; }
|
internal AssetBundle CacheBundle { private set; get; }
|
||||||
|
|
||||||
|
|
||||||
public BundleFileLoader(AssetBundleInfo bundleInfo)
|
public BundleFileLoader(BundleInfo bundleInfo)
|
||||||
{
|
{
|
||||||
BundleInfo = bundleInfo;
|
BundleFileInfo = bundleInfo;
|
||||||
RefCount = 0;
|
RefCount = 0;
|
||||||
States = ELoaderStates.None;
|
States = ELoaderStates.None;
|
||||||
}
|
}
|
||||||
|
@ -92,13 +92,13 @@ namespace YooAsset
|
||||||
if (States == ELoaderStates.None)
|
if (States == ELoaderStates.None)
|
||||||
{
|
{
|
||||||
// 检测加载地址是否为空
|
// 检测加载地址是否为空
|
||||||
if (string.IsNullOrEmpty(BundleInfo.LocalPath))
|
if (string.IsNullOrEmpty(BundleFileInfo.LocalPath))
|
||||||
{
|
{
|
||||||
States = ELoaderStates.Fail;
|
States = ELoaderStates.Fail;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(BundleInfo.RemoteMainURL))
|
if (string.IsNullOrEmpty(BundleFileInfo.RemoteMainURL))
|
||||||
States = ELoaderStates.LoadFile;
|
States = ELoaderStates.LoadFile;
|
||||||
else
|
else
|
||||||
States = ELoaderStates.Download;
|
States = ELoaderStates.Download;
|
||||||
|
@ -108,7 +108,7 @@ namespace YooAsset
|
||||||
if (States == ELoaderStates.Download)
|
if (States == ELoaderStates.Download)
|
||||||
{
|
{
|
||||||
int failedTryAgain = int.MaxValue;
|
int failedTryAgain = int.MaxValue;
|
||||||
_fileDownloader = DownloadSystem.BeginDownload(BundleInfo, failedTryAgain);
|
_fileDownloader = DownloadSystem.BeginDownload(BundleFileInfo, failedTryAgain);
|
||||||
States = ELoaderStates.CheckDownload;
|
States = ELoaderStates.CheckDownload;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,32 +134,32 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
// 注意:Unity2017.4编辑器模式下,如果AssetBundle文件不存在会导致编辑器崩溃,这里做了预判。
|
// 注意:Unity2017.4编辑器模式下,如果AssetBundle文件不存在会导致编辑器崩溃,这里做了预判。
|
||||||
if (System.IO.File.Exists(BundleInfo.LocalPath) == false)
|
if (System.IO.File.Exists(BundleFileInfo.LocalPath) == false)
|
||||||
{
|
{
|
||||||
Logger.Warning($"Not found assetBundle file : {BundleInfo.LocalPath}");
|
Logger.Warning($"Not found assetBundle file : {BundleFileInfo.LocalPath}");
|
||||||
States = ELoaderStates.Fail;
|
States = ELoaderStates.Fail;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Load assetBundle file
|
// Load assetBundle file
|
||||||
if (BundleInfo.IsEncrypted)
|
if (BundleFileInfo.IsEncrypted)
|
||||||
{
|
{
|
||||||
if (AssetSystem.DecryptServices == null)
|
if (AssetSystem.DecryptServices == null)
|
||||||
throw new Exception($"{nameof(BundleFileLoader)} need IDecryptServices : {BundleInfo.BundleName}");
|
throw new Exception($"{nameof(BundleFileLoader)} need IDecryptServices : {BundleFileInfo.BundleName}");
|
||||||
|
|
||||||
EDecryptMethod decryptType = AssetSystem.DecryptServices.DecryptType;
|
EDecryptMethod decryptType = AssetSystem.DecryptServices.DecryptType;
|
||||||
if (decryptType == EDecryptMethod.GetDecryptOffset)
|
if (decryptType == EDecryptMethod.GetDecryptOffset)
|
||||||
{
|
{
|
||||||
ulong offset = AssetSystem.DecryptServices.GetDecryptOffset(BundleInfo);
|
ulong offset = AssetSystem.DecryptServices.GetDecryptOffset(BundleFileInfo);
|
||||||
if (_isWaitForAsyncComplete)
|
if (_isWaitForAsyncComplete)
|
||||||
CacheBundle = AssetBundle.LoadFromFile(BundleInfo.LocalPath, 0, offset);
|
CacheBundle = AssetBundle.LoadFromFile(BundleFileInfo.LocalPath, 0, offset);
|
||||||
else
|
else
|
||||||
_cacheRequest = AssetBundle.LoadFromFileAsync(BundleInfo.LocalPath, 0, offset);
|
_cacheRequest = AssetBundle.LoadFromFileAsync(BundleFileInfo.LocalPath, 0, offset);
|
||||||
}
|
}
|
||||||
else if (decryptType == EDecryptMethod.GetDecryptBinary)
|
else if (decryptType == EDecryptMethod.GetDecryptBinary)
|
||||||
{
|
{
|
||||||
byte[] binary = AssetSystem.DecryptServices.GetDecryptBinary(BundleInfo);
|
byte[] binary = AssetSystem.DecryptServices.GetDecryptBinary(BundleFileInfo);
|
||||||
if (_isWaitForAsyncComplete)
|
if (_isWaitForAsyncComplete)
|
||||||
CacheBundle = AssetBundle.LoadFromMemory(binary);
|
CacheBundle = AssetBundle.LoadFromMemory(binary);
|
||||||
else
|
else
|
||||||
|
@ -173,9 +173,9 @@ namespace YooAsset
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_isWaitForAsyncComplete)
|
if (_isWaitForAsyncComplete)
|
||||||
CacheBundle = AssetBundle.LoadFromFile(BundleInfo.LocalPath);
|
CacheBundle = AssetBundle.LoadFromFile(BundleFileInfo.LocalPath);
|
||||||
else
|
else
|
||||||
_cacheRequest = AssetBundle.LoadFromFileAsync(BundleInfo.LocalPath);
|
_cacheRequest = AssetBundle.LoadFromFileAsync(BundleFileInfo.LocalPath);
|
||||||
}
|
}
|
||||||
States = ELoaderStates.CheckFile;
|
States = ELoaderStates.CheckFile;
|
||||||
}
|
}
|
||||||
|
@ -202,7 +202,7 @@ namespace YooAsset
|
||||||
// Check error
|
// Check error
|
||||||
if (CacheBundle == null)
|
if (CacheBundle == null)
|
||||||
{
|
{
|
||||||
Logger.Error($"Failed to load assetBundle file : {BundleInfo.BundleName}");
|
Logger.Error($"Failed to load assetBundle file : {BundleFileInfo.BundleName}");
|
||||||
States = ELoaderStates.Fail;
|
States = ELoaderStates.Fail;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -223,9 +223,9 @@ namespace YooAsset
|
||||||
if (forceDestroy == false)
|
if (forceDestroy == false)
|
||||||
{
|
{
|
||||||
if (RefCount > 0)
|
if (RefCount > 0)
|
||||||
throw new Exception($"Bundle file loader ref is not zero : {BundleInfo.BundleName}");
|
throw new Exception($"Bundle file loader ref is not zero : {BundleFileInfo.BundleName}");
|
||||||
if (IsDone() == false)
|
if (IsDone() == false)
|
||||||
throw new Exception($"Bundle file loader is not done : {BundleInfo.BundleName}");
|
throw new Exception($"Bundle file loader is not done : {BundleFileInfo.BundleName}");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CacheBundle != null)
|
if (CacheBundle != null)
|
||||||
|
@ -302,7 +302,7 @@ namespace YooAsset
|
||||||
if (_isShowWaitForAsyncError == false)
|
if (_isShowWaitForAsyncError == false)
|
||||||
{
|
{
|
||||||
_isShowWaitForAsyncError = true;
|
_isShowWaitForAsyncError = true;
|
||||||
Logger.Error($"WaitForAsyncComplete failed ! BundleName : {BundleInfo.BundleName} States : {States}");
|
Logger.Error($"WaitForAsyncComplete failed ! BundleName : {BundleFileInfo.BundleName} States : {States}");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,13 +66,13 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源包的调试信息列表
|
/// 获取资源包的调试信息列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal void GetBundleDebugInfos(List<DebugSummy.BundleInfo> output)
|
internal void GetBundleDebugInfos(List<DebugSummy.DebugBundleInfo> output)
|
||||||
{
|
{
|
||||||
foreach (var loader in _dependBundles)
|
foreach (var loader in _dependBundles)
|
||||||
{
|
{
|
||||||
var debugInfo = new DebugSummy.BundleInfo();
|
var debugInfo = new DebugSummy.DebugBundleInfo();
|
||||||
debugInfo.BundleName = loader.BundleInfo.BundleName;
|
debugInfo.BundleName = loader.BundleFileInfo.BundleName;
|
||||||
debugInfo.Version = loader.BundleInfo.Version;
|
debugInfo.Version = loader.BundleFileInfo.Version;
|
||||||
debugInfo.RefCount = loader.RefCount;
|
debugInfo.RefCount = loader.RefCount;
|
||||||
debugInfo.States = loader.States;
|
debugInfo.States = loader.States;
|
||||||
output.Add(debugInfo);
|
output.Add(debugInfo);
|
||||||
|
|
|
@ -97,7 +97,7 @@ namespace YooAsset
|
||||||
|
|
||||||
States = AssetObject == null ? EAssetStates.Fail : EAssetStates.Success;
|
States = AssetObject == null ? EAssetStates.Fail : EAssetStates.Success;
|
||||||
if (States == EAssetStates.Fail)
|
if (States == EAssetStates.Fail)
|
||||||
Logger.Warning($"Failed to load asset : {AssetName} from bundle : {OwnerBundle.BundleInfo.BundleName}");
|
Logger.Warning($"Failed to load asset : {AssetName} from bundle : {OwnerBundle.BundleFileInfo.BundleName}");
|
||||||
InvokeCompletion();
|
InvokeCompletion();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,11 +36,11 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源包的调试信息列表
|
/// 获取资源包的调试信息列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal void GetBundleDebugInfos(List<DebugSummy.BundleInfo> output)
|
internal void GetBundleDebugInfos(List<DebugSummy.DebugBundleInfo> output)
|
||||||
{
|
{
|
||||||
var ownerInfo = new DebugSummy.BundleInfo();
|
var ownerInfo = new DebugSummy.DebugBundleInfo();
|
||||||
ownerInfo.BundleName = OwnerBundle.BundleInfo.BundleName;
|
ownerInfo.BundleName = OwnerBundle.BundleFileInfo.BundleName;
|
||||||
ownerInfo.Version = OwnerBundle.BundleInfo.Version;
|
ownerInfo.Version = OwnerBundle.BundleFileInfo.Version;
|
||||||
ownerInfo.RefCount = OwnerBundle.RefCount;
|
ownerInfo.RefCount = OwnerBundle.RefCount;
|
||||||
ownerInfo.States = OwnerBundle.States;
|
ownerInfo.States = OwnerBundle.States;
|
||||||
output.Add(ownerInfo);
|
output.Add(ownerInfo);
|
||||||
|
|
|
@ -97,7 +97,7 @@ namespace YooAsset
|
||||||
|
|
||||||
States = AllAssets == null ? EAssetStates.Fail : EAssetStates.Success;
|
States = AllAssets == null ? EAssetStates.Fail : EAssetStates.Success;
|
||||||
if (States == EAssetStates.Fail)
|
if (States == EAssetStates.Fail)
|
||||||
Logger.Warning($"Failed to load sub assets : {AssetName} from bundle : {OwnerBundle.BundleInfo.BundleName}");
|
Logger.Warning($"Failed to load sub assets : {AssetName} from bundle : {OwnerBundle.BundleFileInfo.BundleName}");
|
||||||
InvokeCompletion();
|
InvokeCompletion();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包调试信息
|
/// 资源包调试信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class BundleInfo
|
public class DebugBundleInfo
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包名称
|
/// 资源包名称
|
||||||
|
@ -35,7 +35,7 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源加载对象调试信息
|
/// 资源加载对象调试信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ProviderInfo : IComparer<ProviderInfo>, IComparable<ProviderInfo>
|
public class DebugProviderInfo : IComparer<DebugProviderInfo>, IComparable<DebugProviderInfo>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源对象路径
|
/// 资源对象路径
|
||||||
|
@ -55,20 +55,20 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 依赖的资源包列表
|
/// 依赖的资源包列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly List<BundleInfo> BundleInfos = new List<BundleInfo>();
|
public readonly List<DebugBundleInfo> BundleInfos = new List<DebugBundleInfo>();
|
||||||
|
|
||||||
public int CompareTo(ProviderInfo other)
|
public int CompareTo(DebugProviderInfo other)
|
||||||
{
|
{
|
||||||
return Compare(this, other);
|
return Compare(this, other);
|
||||||
}
|
}
|
||||||
public int Compare(ProviderInfo a, ProviderInfo b)
|
public int Compare(DebugProviderInfo a, DebugProviderInfo b)
|
||||||
{
|
{
|
||||||
return string.CompareOrdinal(a.AssetPath, b.AssetPath);
|
return string.CompareOrdinal(a.AssetPath, b.AssetPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public readonly List<ProviderInfo> ProviderInfos = new List<ProviderInfo>(1000);
|
public readonly List<DebugProviderInfo> ProviderInfos = new List<DebugProviderInfo>(1000);
|
||||||
public int BundleCount { set; get; }
|
public int BundleCount { set; get; }
|
||||||
public int AssetCount { set; get; }
|
public int AssetCount { set; get; }
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ namespace YooAsset
|
||||||
/// 开始下载资源文件
|
/// 开始下载资源文件
|
||||||
/// 注意:只有第一次请求的参数才是有效的
|
/// 注意:只有第一次请求的参数才是有效的
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static FileDownloader BeginDownload(AssetBundleInfo bundleInfo, int failedTryAgain, int timeout = 60)
|
public static FileDownloader BeginDownload(BundleInfo bundleInfo, int failedTryAgain, int timeout = 60)
|
||||||
{
|
{
|
||||||
// 查询存在的下载器
|
// 查询存在的下载器
|
||||||
if (_downloaderDic.TryGetValue(bundleInfo.Hash, out var downloader))
|
if (_downloaderDic.TryGetValue(bundleInfo.Hash, out var downloader))
|
||||||
|
@ -119,7 +119,7 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
// 验证文件完整性
|
// 验证文件完整性
|
||||||
public static bool CheckContentIntegrity(AssetBundleInfo bundleInfo)
|
public static bool CheckContentIntegrity(BundleInfo bundleInfo)
|
||||||
{
|
{
|
||||||
return CheckContentIntegrity(bundleInfo.LocalPath, bundleInfo.SizeBytes, bundleInfo.CRC);
|
return CheckContentIntegrity(bundleInfo.LocalPath, bundleInfo.SizeBytes, bundleInfo.CRC);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace YooAsset
|
||||||
Failed,
|
Failed,
|
||||||
}
|
}
|
||||||
|
|
||||||
public AssetBundleInfo BundleInfo { private set; get; }
|
private readonly BundleInfo _bundleInfo;
|
||||||
private UnityWebRequest _webRequest;
|
private UnityWebRequest _webRequest;
|
||||||
private UnityWebRequestAsyncOperation _operationHandle;
|
private UnityWebRequestAsyncOperation _operationHandle;
|
||||||
|
|
||||||
|
@ -48,13 +48,13 @@ namespace YooAsset
|
||||||
public ulong DownloadedBytes { private set; get; }
|
public ulong DownloadedBytes { private set; get; }
|
||||||
|
|
||||||
|
|
||||||
internal FileDownloader(AssetBundleInfo bundleInfo)
|
internal FileDownloader(BundleInfo bundleInfo)
|
||||||
{
|
{
|
||||||
BundleInfo = bundleInfo;
|
_bundleInfo = bundleInfo;
|
||||||
}
|
}
|
||||||
internal void SendRequest(int failedTryAgain, int timeout)
|
internal void SendRequest(int failedTryAgain, int timeout)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(BundleInfo.LocalPath))
|
if (string.IsNullOrEmpty(_bundleInfo.LocalPath))
|
||||||
throw new ArgumentNullException();
|
throw new ArgumentNullException();
|
||||||
|
|
||||||
if (_steps == ESteps.None)
|
if (_steps == ESteps.None)
|
||||||
|
@ -85,7 +85,7 @@ namespace YooAsset
|
||||||
_requestCount++;
|
_requestCount++;
|
||||||
_requestURL = GetRequestURL();
|
_requestURL = GetRequestURL();
|
||||||
_webRequest = new UnityWebRequest(_requestURL, UnityWebRequest.kHttpVerbGET);
|
_webRequest = new UnityWebRequest(_requestURL, UnityWebRequest.kHttpVerbGET);
|
||||||
DownloadHandlerFile handler = new DownloadHandlerFile(BundleInfo.LocalPath);
|
DownloadHandlerFile handler = new DownloadHandlerFile(_bundleInfo.LocalPath);
|
||||||
handler.removeFileOnAbort = true;
|
handler.removeFileOnAbort = true;
|
||||||
_webRequest.downloadHandler = handler;
|
_webRequest.downloadHandler = handler;
|
||||||
_webRequest.disposeDownloadHandlerOnDispose = true;
|
_webRequest.disposeDownloadHandlerOnDispose = true;
|
||||||
|
@ -124,12 +124,12 @@ namespace YooAsset
|
||||||
if (isError == false)
|
if (isError == false)
|
||||||
{
|
{
|
||||||
// 注意:如果文件验证失败需要删除文件
|
// 注意:如果文件验证失败需要删除文件
|
||||||
if (DownloadSystem.CheckContentIntegrity(BundleInfo) == false)
|
if (DownloadSystem.CheckContentIntegrity(_bundleInfo) == false)
|
||||||
{
|
{
|
||||||
isError = true;
|
isError = true;
|
||||||
_lastError = $"Verification failed";
|
_lastError = $"Verification failed";
|
||||||
if (File.Exists(BundleInfo.LocalPath))
|
if (File.Exists(_bundleInfo.LocalPath))
|
||||||
File.Delete(BundleInfo.LocalPath);
|
File.Delete(_bundleInfo.LocalPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ namespace YooAsset
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_steps = ESteps.Succeed;
|
_steps = ESteps.Succeed;
|
||||||
DownloadSystem.CacheVerifyFile(BundleInfo.Hash, BundleInfo.BundleName);
|
DownloadSystem.CacheVerifyFile(_bundleInfo.Hash, _bundleInfo.BundleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 释放下载器
|
// 释放下载器
|
||||||
|
@ -172,9 +172,9 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
// 轮流返回请求地址
|
// 轮流返回请求地址
|
||||||
if (_requestCount % 2 == 0)
|
if (_requestCount % 2 == 0)
|
||||||
return BundleInfo.RemoteFallbackURL;
|
return _bundleInfo.RemoteFallbackURL;
|
||||||
else
|
else
|
||||||
return BundleInfo.RemoteMainURL;
|
return _bundleInfo.RemoteMainURL;
|
||||||
}
|
}
|
||||||
private void CheckTimeout()
|
private void CheckTimeout()
|
||||||
{
|
{
|
||||||
|
@ -206,6 +206,14 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取资源包信息
|
||||||
|
/// </summary>
|
||||||
|
public BundleInfo GetBundleInfo()
|
||||||
|
{
|
||||||
|
return _bundleInfo;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 检测下载器是否已经完成(无论成功或失败)
|
/// 检测下载器是否已经完成(无论成功或失败)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace YooAsset
|
||||||
Failed,
|
Failed,
|
||||||
}
|
}
|
||||||
|
|
||||||
public AssetBundleInfo BundleInfo { private set; get; }
|
private readonly BundleInfo _bundleInfo;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
// 线程
|
// 线程
|
||||||
|
@ -61,6 +61,10 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
internal HttpDownloader(BundleInfo bundleInfo)
|
||||||
|
{
|
||||||
|
_bundleInfo = bundleInfo;
|
||||||
|
}
|
||||||
internal void SendRequest(int failedTryAgain, int timeout)
|
internal void SendRequest(int failedTryAgain, int timeout)
|
||||||
{
|
{
|
||||||
_failedTryAgain = failedTryAgain;
|
_failedTryAgain = failedTryAgain;
|
||||||
|
@ -102,7 +106,7 @@ namespace YooAsset
|
||||||
_downloadError = _threadError;
|
_downloadError = _threadError;
|
||||||
if (_threadResult)
|
if (_threadResult)
|
||||||
{
|
{
|
||||||
DownloadSystem.CacheVerifyFile(BundleInfo.Hash, BundleInfo.BundleName);
|
DownloadSystem.CacheVerifyFile(_bundleInfo.Hash, _bundleInfo.BundleName);
|
||||||
_steps = ESteps.Succeed;
|
_steps = ESteps.Succeed;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -125,6 +129,14 @@ namespace YooAsset
|
||||||
_steps = ESteps.Succeed;
|
_steps = ESteps.Succeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取资源包信息
|
||||||
|
/// </summary>
|
||||||
|
public BundleInfo GetBundleInfo()
|
||||||
|
{
|
||||||
|
return _bundleInfo;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 检测下载器是否已经完成(无论成功或失败)
|
/// 检测下载器是否已经完成(无论成功或失败)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -155,8 +167,8 @@ namespace YooAsset
|
||||||
private void ThreadRun()
|
private void ThreadRun()
|
||||||
{
|
{
|
||||||
string url = GetRequestURL();
|
string url = GetRequestURL();
|
||||||
string savePath = BundleInfo.LocalPath;
|
string savePath = _bundleInfo.LocalPath;
|
||||||
long fileTotalSize = BundleInfo.SizeBytes;
|
long fileTotalSize = _bundleInfo.SizeBytes;
|
||||||
|
|
||||||
FileStream fileStream = null;
|
FileStream fileStream = null;
|
||||||
Stream webStream = null;
|
Stream webStream = null;
|
||||||
|
@ -202,7 +214,7 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
// 验证下载文件完整性
|
// 验证下载文件完整性
|
||||||
bool verfiyResult = DownloadSystem.CheckContentIntegrity(savePath, BundleInfo.SizeBytes, BundleInfo.CRC);
|
bool verfiyResult = DownloadSystem.CheckContentIntegrity(savePath, _bundleInfo.SizeBytes, _bundleInfo.CRC);
|
||||||
if(verfiyResult)
|
if(verfiyResult)
|
||||||
{
|
{
|
||||||
_threadResult = true;
|
_threadResult = true;
|
||||||
|
@ -210,7 +222,7 @@ namespace YooAsset
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_threadResult = false;
|
_threadResult = false;
|
||||||
_threadError = $"Verify file content failed : {BundleInfo.Hash}";
|
_threadError = $"Verify file content failed : {_bundleInfo.Hash}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@ -245,9 +257,9 @@ namespace YooAsset
|
||||||
// 轮流返回请求地址
|
// 轮流返回请求地址
|
||||||
_requestCount++;
|
_requestCount++;
|
||||||
if (_requestCount % 2 == 0)
|
if (_requestCount % 2 == 0)
|
||||||
return BundleInfo.RemoteFallbackURL;
|
return _bundleInfo.RemoteFallbackURL;
|
||||||
else
|
else
|
||||||
return BundleInfo.RemoteMainURL;
|
return _bundleInfo.RemoteMainURL;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,8 @@ namespace YooAsset
|
||||||
|
|
||||||
private readonly int _fileLoadingMaxNumber;
|
private readonly int _fileLoadingMaxNumber;
|
||||||
private readonly int _failedTryAgain;
|
private readonly int _failedTryAgain;
|
||||||
private readonly List<AssetBundleInfo> _downloadList;
|
private readonly List<BundleInfo> _downloadList;
|
||||||
private readonly List<AssetBundleInfo> _loadFailedList = new List<AssetBundleInfo>();
|
private readonly List<BundleInfo> _loadFailedList = new List<BundleInfo>();
|
||||||
private readonly List<FileDownloader> _downloaders = new List<FileDownloader>();
|
private readonly List<FileDownloader> _downloaders = new List<FileDownloader>();
|
||||||
private readonly List<FileDownloader> _removeList = new List<FileDownloader>(MAX_LOADER_COUNT);
|
private readonly List<FileDownloader> _removeList = new List<FileDownloader>(MAX_LOADER_COUNT);
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ namespace YooAsset
|
||||||
public OnDownloadFileFailed OnDownloadFileFailedCallback { set; get; }
|
public OnDownloadFileFailed OnDownloadFileFailedCallback { set; get; }
|
||||||
|
|
||||||
|
|
||||||
internal DownloaderOperation(List<AssetBundleInfo> downloadList, int fileLoadingMaxNumber, int failedTryAgain)
|
internal DownloaderOperation(List<BundleInfo> downloadList, int fileLoadingMaxNumber, int failedTryAgain)
|
||||||
{
|
{
|
||||||
_downloadList = downloadList;
|
_downloadList = downloadList;
|
||||||
_fileLoadingMaxNumber = UnityEngine.Mathf.Clamp(fileLoadingMaxNumber, 1, MAX_LOADER_COUNT); ;
|
_fileLoadingMaxNumber = UnityEngine.Mathf.Clamp(fileLoadingMaxNumber, 1, MAX_LOADER_COUNT); ;
|
||||||
|
@ -100,7 +100,7 @@ namespace YooAsset
|
||||||
if (downloader.IsDone() == false)
|
if (downloader.IsDone() == false)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
AssetBundleInfo bundleInfo = downloader.BundleInfo;
|
BundleInfo bundleInfo = downloader.GetBundleInfo();
|
||||||
|
|
||||||
// 检测是否下载失败
|
// 检测是否下载失败
|
||||||
if (downloader.HasError())
|
if (downloader.HasError())
|
||||||
|
|
|
@ -87,7 +87,7 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源包名称
|
/// 获取资源包名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string GetAssetBundleName(string assetPath)
|
public string GetBundleName(string assetPath)
|
||||||
{
|
{
|
||||||
if (Assets.TryGetValue(assetPath, out PatchAsset patchAsset))
|
if (Assets.TryGetValue(assetPath, out PatchAsset patchAsset))
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,13 +25,13 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
#region IBundleServices接口
|
#region IBundleServices接口
|
||||||
AssetBundleInfo IBundleServices.GetAssetBundleInfo(string bundleName)
|
BundleInfo IBundleServices.GetBundleInfo(string bundleName)
|
||||||
{
|
{
|
||||||
Logger.Warning($"Editor play mode can not get asset bundle info.");
|
Logger.Warning($"Editor play mode can not get bundle info.");
|
||||||
AssetBundleInfo bundleInfo = new AssetBundleInfo(bundleName, bundleName);
|
BundleInfo bundleInfo = new BundleInfo(bundleName, bundleName);
|
||||||
return bundleInfo;
|
return bundleInfo;
|
||||||
}
|
}
|
||||||
string IBundleServices.GetAssetBundleName(string assetPath)
|
string IBundleServices.GetBundleName(string assetPath)
|
||||||
{
|
{
|
||||||
return assetPath;
|
return assetPath;
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,11 +57,11 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DownloaderOperation CreateDownloaderByTags(string[] tags, int fileLoadingMaxNumber, int failedTryAgain)
|
public DownloaderOperation CreateDownloaderByTags(string[] tags, int fileLoadingMaxNumber, int failedTryAgain)
|
||||||
{
|
{
|
||||||
List<AssetBundleInfo> downloadList = GetDownloadListByTags(tags);
|
List<BundleInfo> downloadList = GetDownloadListByTags(tags);
|
||||||
var operation = new DownloaderOperation(downloadList, fileLoadingMaxNumber, failedTryAgain);
|
var operation = new DownloaderOperation(downloadList, fileLoadingMaxNumber, failedTryAgain);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
private List<AssetBundleInfo> GetDownloadListByTags(string[] tags)
|
private List<BundleInfo> GetDownloadListByTags(string[] tags)
|
||||||
{
|
{
|
||||||
List<PatchBundle> downloadList = new List<PatchBundle>(1000);
|
List<PatchBundle> downloadList = new List<PatchBundle>(1000);
|
||||||
foreach (var patchBundle in LocalPatchManifest.BundleList)
|
foreach (var patchBundle in LocalPatchManifest.BundleList)
|
||||||
|
@ -103,17 +103,17 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DownloaderOperation CreateDownloaderByPaths(List<string> assetPaths, int fileLoadingMaxNumber, int failedTryAgain)
|
public DownloaderOperation CreateDownloaderByPaths(List<string> assetPaths, int fileLoadingMaxNumber, int failedTryAgain)
|
||||||
{
|
{
|
||||||
List<AssetBundleInfo> downloadList = GetDownloadListByPaths(assetPaths);
|
List<BundleInfo> downloadList = GetDownloadListByPaths(assetPaths);
|
||||||
var operation = new DownloaderOperation(downloadList, fileLoadingMaxNumber, failedTryAgain);
|
var operation = new DownloaderOperation(downloadList, fileLoadingMaxNumber, failedTryAgain);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
private List<AssetBundleInfo> GetDownloadListByPaths(List<string> assetPaths)
|
private List<BundleInfo> GetDownloadListByPaths(List<string> assetPaths)
|
||||||
{
|
{
|
||||||
// 获取资源对象的资源包和所有依赖资源包
|
// 获取资源对象的资源包和所有依赖资源包
|
||||||
List<PatchBundle> checkList = new List<PatchBundle>();
|
List<PatchBundle> checkList = new List<PatchBundle>();
|
||||||
foreach (var assetPath in assetPaths)
|
foreach (var assetPath in assetPaths)
|
||||||
{
|
{
|
||||||
string mainBundleName = LocalPatchManifest.GetAssetBundleName(assetPath);
|
string mainBundleName = LocalPatchManifest.GetBundleName(assetPath);
|
||||||
if (string.IsNullOrEmpty(mainBundleName) == false)
|
if (string.IsNullOrEmpty(mainBundleName) == false)
|
||||||
{
|
{
|
||||||
if (LocalPatchManifest.Bundles.TryGetValue(mainBundleName, out PatchBundle mainBundle))
|
if (LocalPatchManifest.Bundles.TryGetValue(mainBundleName, out PatchBundle mainBundle))
|
||||||
|
@ -160,11 +160,11 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DownloaderOperation CreateUnpackerByTags(string[] tags, int fileUpackingMaxNumber, int failedTryAgain)
|
public DownloaderOperation CreateUnpackerByTags(string[] tags, int fileUpackingMaxNumber, int failedTryAgain)
|
||||||
{
|
{
|
||||||
List<AssetBundleInfo> unpcakList = GetUnpackListByTags(tags);
|
List<BundleInfo> unpcakList = GetUnpackListByTags(tags);
|
||||||
var operation = new DownloaderOperation(unpcakList, fileUpackingMaxNumber, failedTryAgain);
|
var operation = new DownloaderOperation(unpcakList, fileUpackingMaxNumber, failedTryAgain);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
private List<AssetBundleInfo> GetUnpackListByTags(string[] tags)
|
private List<BundleInfo> GetUnpackListByTags(string[] tags)
|
||||||
{
|
{
|
||||||
List<PatchBundle> downloadList = new List<PatchBundle>(1000);
|
List<PatchBundle> downloadList = new List<PatchBundle>(1000);
|
||||||
foreach (var patchBundle in AppPatchManifest.BundleList)
|
foreach (var patchBundle in AppPatchManifest.BundleList)
|
||||||
|
@ -213,18 +213,18 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
// 下载相关
|
// 下载相关
|
||||||
private AssetBundleInfo ConvertToDownloadInfo(PatchBundle patchBundle)
|
private BundleInfo ConvertToDownloadInfo(PatchBundle patchBundle)
|
||||||
{
|
{
|
||||||
// 注意:资源版本号只用于确定下载路径
|
// 注意:资源版本号只用于确定下载路径
|
||||||
string sandboxPath = PatchHelper.MakeSandboxCacheFilePath(patchBundle.Hash);
|
string sandboxPath = PatchHelper.MakeSandboxCacheFilePath(patchBundle.Hash);
|
||||||
string remoteMainURL = GetPatchDownloadMainURL(patchBundle.Version, patchBundle.Hash);
|
string remoteMainURL = GetPatchDownloadMainURL(patchBundle.Version, patchBundle.Hash);
|
||||||
string remoteFallbackURL = GetPatchDownloadFallbackURL(patchBundle.Version, patchBundle.Hash);
|
string remoteFallbackURL = GetPatchDownloadFallbackURL(patchBundle.Version, patchBundle.Hash);
|
||||||
AssetBundleInfo bundleInfo = new AssetBundleInfo(patchBundle, sandboxPath, remoteMainURL, remoteFallbackURL);
|
BundleInfo bundleInfo = new BundleInfo(patchBundle, sandboxPath, remoteMainURL, remoteFallbackURL);
|
||||||
return bundleInfo;
|
return bundleInfo;
|
||||||
}
|
}
|
||||||
private List<AssetBundleInfo> ConvertToDownloadList(List<PatchBundle> downloadList)
|
private List<BundleInfo> ConvertToDownloadList(List<PatchBundle> downloadList)
|
||||||
{
|
{
|
||||||
List<AssetBundleInfo> result = new List<AssetBundleInfo>(downloadList.Count);
|
List<BundleInfo> result = new List<BundleInfo>(downloadList.Count);
|
||||||
foreach (var patchBundle in downloadList)
|
foreach (var patchBundle in downloadList)
|
||||||
{
|
{
|
||||||
var bundleInfo = ConvertToDownloadInfo(patchBundle);
|
var bundleInfo = ConvertToDownloadInfo(patchBundle);
|
||||||
|
@ -234,16 +234,16 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
// 解压相关
|
// 解压相关
|
||||||
private AssetBundleInfo ConvertToUnpackInfo(PatchBundle patchBundle)
|
private BundleInfo ConvertToUnpackInfo(PatchBundle patchBundle)
|
||||||
{
|
{
|
||||||
string sandboxPath = PatchHelper.MakeSandboxCacheFilePath(patchBundle.Hash);
|
string sandboxPath = PatchHelper.MakeSandboxCacheFilePath(patchBundle.Hash);
|
||||||
string streamingLoadPath = AssetPathHelper.MakeStreamingLoadPath(patchBundle.Hash);
|
string streamingLoadPath = AssetPathHelper.MakeStreamingLoadPath(patchBundle.Hash);
|
||||||
AssetBundleInfo bundleInfo = new AssetBundleInfo(patchBundle, sandboxPath, streamingLoadPath, streamingLoadPath);
|
BundleInfo bundleInfo = new BundleInfo(patchBundle, sandboxPath, streamingLoadPath, streamingLoadPath);
|
||||||
return bundleInfo;
|
return bundleInfo;
|
||||||
}
|
}
|
||||||
private List<AssetBundleInfo> ConvertToUnpackList(List<PatchBundle> unpackList)
|
private List<BundleInfo> ConvertToUnpackList(List<PatchBundle> unpackList)
|
||||||
{
|
{
|
||||||
List<AssetBundleInfo> result = new List<AssetBundleInfo>(unpackList.Count);
|
List<BundleInfo> result = new List<BundleInfo>(unpackList.Count);
|
||||||
foreach (var patchBundle in unpackList)
|
foreach (var patchBundle in unpackList)
|
||||||
{
|
{
|
||||||
var bundleInfo = ConvertToUnpackInfo(patchBundle);
|
var bundleInfo = ConvertToUnpackInfo(patchBundle);
|
||||||
|
@ -253,10 +253,10 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
#region IBundleServices接口
|
#region IBundleServices接口
|
||||||
AssetBundleInfo IBundleServices.GetAssetBundleInfo(string bundleName)
|
BundleInfo IBundleServices.GetBundleInfo(string bundleName)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(bundleName))
|
if (string.IsNullOrEmpty(bundleName))
|
||||||
return new AssetBundleInfo(string.Empty, string.Empty);
|
return new BundleInfo(string.Empty, string.Empty);
|
||||||
|
|
||||||
if (LocalPatchManifest.Bundles.TryGetValue(bundleName, out PatchBundle patchBundle))
|
if (LocalPatchManifest.Bundles.TryGetValue(bundleName, out PatchBundle patchBundle))
|
||||||
{
|
{
|
||||||
|
@ -266,7 +266,7 @@ namespace YooAsset
|
||||||
if (appPatchBundle.IsBuildin && appPatchBundle.Hash == patchBundle.Hash)
|
if (appPatchBundle.IsBuildin && appPatchBundle.Hash == patchBundle.Hash)
|
||||||
{
|
{
|
||||||
string appLoadPath = AssetPathHelper.MakeStreamingLoadPath(appPatchBundle.Hash);
|
string appLoadPath = AssetPathHelper.MakeStreamingLoadPath(appPatchBundle.Hash);
|
||||||
AssetBundleInfo bundleInfo = new AssetBundleInfo(appPatchBundle, appLoadPath);
|
BundleInfo bundleInfo = new BundleInfo(appPatchBundle, appLoadPath);
|
||||||
return bundleInfo;
|
return bundleInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -275,7 +275,7 @@ namespace YooAsset
|
||||||
if (DownloadSystem.ContainsVerifyFile(patchBundle.Hash))
|
if (DownloadSystem.ContainsVerifyFile(patchBundle.Hash))
|
||||||
{
|
{
|
||||||
string sandboxLoadPath = PatchHelper.MakeSandboxCacheFilePath(patchBundle.Hash);
|
string sandboxLoadPath = PatchHelper.MakeSandboxCacheFilePath(patchBundle.Hash);
|
||||||
AssetBundleInfo bundleInfo = new AssetBundleInfo(patchBundle, sandboxLoadPath);
|
BundleInfo bundleInfo = new BundleInfo(patchBundle, sandboxLoadPath);
|
||||||
return bundleInfo;
|
return bundleInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,13 +285,13 @@ namespace YooAsset
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Logger.Warning($"Not found bundle in patch manifest : {bundleName}");
|
Logger.Warning($"Not found bundle in patch manifest : {bundleName}");
|
||||||
AssetBundleInfo bundleInfo = new AssetBundleInfo(bundleName, string.Empty);
|
BundleInfo bundleInfo = new BundleInfo(bundleName, string.Empty);
|
||||||
return bundleInfo;
|
return bundleInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
string IBundleServices.GetAssetBundleName(string assetPath)
|
string IBundleServices.GetBundleName(string assetPath)
|
||||||
{
|
{
|
||||||
return LocalPatchManifest.GetAssetBundleName(assetPath);
|
return LocalPatchManifest.GetBundleName(assetPath);
|
||||||
}
|
}
|
||||||
string[] IBundleServices.GetAllDependencies(string assetPath)
|
string[] IBundleServices.GetAllDependencies(string assetPath)
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,27 +29,27 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
#region IBundleServices接口
|
#region IBundleServices接口
|
||||||
AssetBundleInfo IBundleServices.GetAssetBundleInfo(string bundleName)
|
BundleInfo IBundleServices.GetBundleInfo(string bundleName)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(bundleName))
|
if (string.IsNullOrEmpty(bundleName))
|
||||||
return new AssetBundleInfo(string.Empty, string.Empty);
|
return new BundleInfo(string.Empty, string.Empty);
|
||||||
|
|
||||||
if (AppPatchManifest.Bundles.TryGetValue(bundleName, out PatchBundle patchBundle))
|
if (AppPatchManifest.Bundles.TryGetValue(bundleName, out PatchBundle patchBundle))
|
||||||
{
|
{
|
||||||
string localPath = AssetPathHelper.MakeStreamingLoadPath(patchBundle.Hash);
|
string localPath = AssetPathHelper.MakeStreamingLoadPath(patchBundle.Hash);
|
||||||
AssetBundleInfo bundleInfo = new AssetBundleInfo(patchBundle, localPath);
|
BundleInfo bundleInfo = new BundleInfo(patchBundle, localPath);
|
||||||
return bundleInfo;
|
return bundleInfo;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Logger.Warning($"Not found bundle in patch manifest : {bundleName}");
|
Logger.Warning($"Not found bundle in patch manifest : {bundleName}");
|
||||||
AssetBundleInfo bundleInfo = new AssetBundleInfo(bundleName, string.Empty);
|
BundleInfo bundleInfo = new BundleInfo(bundleName, string.Empty);
|
||||||
return bundleInfo;
|
return bundleInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
string IBundleServices.GetAssetBundleName(string assetPath)
|
string IBundleServices.GetBundleName(string assetPath)
|
||||||
{
|
{
|
||||||
return AppPatchManifest.GetAssetBundleName(assetPath);
|
return AppPatchManifest.GetBundleName(assetPath);
|
||||||
}
|
}
|
||||||
string[] IBundleServices.GetAllDependencies(string assetPath)
|
string[] IBundleServices.GetAllDependencies(string assetPath)
|
||||||
{
|
{
|
||||||
|
|
|
@ -254,11 +254,11 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源包信息
|
/// 获取资源包信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static AssetBundleInfo GetAssetBundleInfo(string location)
|
public static BundleInfo GetBundleInfo(string location)
|
||||||
{
|
{
|
||||||
string assetPath = ConvertLocationToAssetPath(location);
|
string assetPath = ConvertLocationToAssetPath(location);
|
||||||
string bundleName = _bundleServices.GetAssetBundleName(assetPath);
|
string bundleName = _bundleServices.GetBundleName(assetPath);
|
||||||
return _bundleServices.GetAssetBundleInfo(bundleName);
|
return _bundleServices.GetBundleInfo(bundleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -393,13 +393,13 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
if (_playMode == EPlayMode.EditorPlayMode)
|
if (_playMode == EPlayMode.EditorPlayMode)
|
||||||
{
|
{
|
||||||
List<AssetBundleInfo> downloadList = new List<AssetBundleInfo>();
|
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||||
var operation = new DownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain);
|
var operation = new DownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
else if (_playMode == EPlayMode.OfflinePlayMode)
|
else if (_playMode == EPlayMode.OfflinePlayMode)
|
||||||
{
|
{
|
||||||
List<AssetBundleInfo> downloadList = new List<AssetBundleInfo>();
|
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||||
var operation = new DownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain);
|
var operation = new DownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
@ -425,13 +425,13 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
if (_playMode == EPlayMode.EditorPlayMode)
|
if (_playMode == EPlayMode.EditorPlayMode)
|
||||||
{
|
{
|
||||||
List<AssetBundleInfo> downloadList = new List<AssetBundleInfo>();
|
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||||
var operation = new DownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain);
|
var operation = new DownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
else if (_playMode == EPlayMode.OfflinePlayMode)
|
else if (_playMode == EPlayMode.OfflinePlayMode)
|
||||||
{
|
{
|
||||||
List<AssetBundleInfo> downloadList = new List<AssetBundleInfo>();
|
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||||
var operation = new DownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain);
|
var operation = new DownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
@ -477,13 +477,13 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
if (_playMode == EPlayMode.EditorPlayMode)
|
if (_playMode == EPlayMode.EditorPlayMode)
|
||||||
{
|
{
|
||||||
List<AssetBundleInfo> downloadList = new List<AssetBundleInfo>();
|
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||||
var operation = new DownloaderOperation(downloadList, unpackingMaxNumber, failedTryAgain);
|
var operation = new DownloaderOperation(downloadList, unpackingMaxNumber, failedTryAgain);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
else if (_playMode == EPlayMode.OfflinePlayMode)
|
else if (_playMode == EPlayMode.OfflinePlayMode)
|
||||||
{
|
{
|
||||||
List<AssetBundleInfo> downloadList = new List<AssetBundleInfo>();
|
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||||
var operation = new DownloaderOperation(downloadList, unpackingMaxNumber, failedTryAgain);
|
var operation = new DownloaderOperation(downloadList, unpackingMaxNumber, failedTryAgain);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue