update resource package

pull/189/head
hevinci 2023-09-25 16:30:24 +08:00
parent 8fe2fa7bc6
commit eb98eaeb3b
7 changed files with 30 additions and 28 deletions

View File

@ -348,7 +348,7 @@ namespace YooAsset
} }
internal List<BundleLoaderBase> CreateDependAssetBundleLoaders(AssetInfo assetInfo) internal List<BundleLoaderBase> CreateDependAssetBundleLoaders(AssetInfo assetInfo)
{ {
BundleInfo[] depends = _bundleQuery.GetAllDependBundleInfos(assetInfo); BundleInfo[] depends = _bundleQuery.GetDependBundleInfos(assetInfo);
List<BundleLoaderBase> result = new List<BundleLoaderBase>(depends.Length); List<BundleLoaderBase> result = new List<BundleLoaderBase>(depends.Length);
foreach (var bundleInfo in depends) foreach (var bundleInfo in depends)
{ {

View File

@ -11,7 +11,7 @@ namespace YooAsset
/// <summary> /// <summary>
/// 获取依赖的资源包信息集合 /// 获取依赖的资源包信息集合
/// </summary> /// </summary>
BundleInfo[] GetAllDependBundleInfos(AssetInfo assetPath); BundleInfo[] GetDependBundleInfos(AssetInfo assetPath);
/// <summary> /// <summary>
/// 清单是否有效 /// 清单是否有效

View File

@ -111,7 +111,7 @@ namespace YooAsset
var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath); var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath);
return CreateBundleInfo(packageBundle, assetInfo); return CreateBundleInfo(packageBundle, assetInfo);
} }
BundleInfo[] IBundleQuery.GetAllDependBundleInfos(AssetInfo assetInfo) BundleInfo[] IBundleQuery.GetDependBundleInfos(AssetInfo assetInfo)
{ {
if (assetInfo.IsInvalid) if (assetInfo.IsInvalid)
throw new Exception("Should never get here !"); throw new Exception("Should never get here !");

View File

@ -366,7 +366,7 @@ namespace YooAsset
var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath); var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath);
return CreateBundleInfo(packageBundle); return CreateBundleInfo(packageBundle);
} }
BundleInfo[] IBundleQuery.GetAllDependBundleInfos(AssetInfo assetInfo) BundleInfo[] IBundleQuery.GetDependBundleInfos(AssetInfo assetInfo)
{ {
if (assetInfo.IsInvalid) if (assetInfo.IsInvalid)
throw new Exception("Should never get here !"); throw new Exception("Should never get here !");

View File

@ -195,7 +195,7 @@ namespace YooAsset
var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath); var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath);
return CreateBundleInfo(packageBundle); return CreateBundleInfo(packageBundle);
} }
BundleInfo[] IBundleQuery.GetAllDependBundleInfos(AssetInfo assetInfo) BundleInfo[] IBundleQuery.GetDependBundleInfos(AssetInfo assetInfo)
{ {
if (assetInfo.IsInvalid) if (assetInfo.IsInvalid)
throw new Exception("Should never get here !"); throw new Exception("Should never get here !");

View File

@ -144,7 +144,7 @@ namespace YooAsset
var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath); var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath);
return CreateBundleInfo(packageBundle); return CreateBundleInfo(packageBundle);
} }
BundleInfo[] IBundleQuery.GetAllDependBundleInfos(AssetInfo assetInfo) BundleInfo[] IBundleQuery.GetDependBundleInfos(AssetInfo assetInfo)
{ {
if (assetInfo.IsInvalid) if (assetInfo.IsInvalid)
throw new Exception("Should never get here !"); throw new Exception("Should never get here !");

View File

@ -403,17 +403,7 @@ namespace YooAsset
{ {
DebugCheckInitialize(); DebugCheckInitialize();
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null); AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
if (assetInfo.IsInvalid) return IsNeedDownloadFromRemoteInternal(assetInfo);
{
YooLogger.Warning(assetInfo.Error);
return false;
}
BundleInfo bundleInfo = _bundleQuery.GetMainBundleInfo(assetInfo);
if (bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromRemote)
return true;
else
return false;
} }
/// <summary> /// <summary>
@ -423,17 +413,7 @@ namespace YooAsset
public bool IsNeedDownloadFromRemote(AssetInfo assetInfo) public bool IsNeedDownloadFromRemote(AssetInfo assetInfo)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
if (assetInfo.IsInvalid) return IsNeedDownloadFromRemoteInternal(assetInfo);
{
YooLogger.Warning(assetInfo.Error);
return false;
}
BundleInfo bundleInfo = _bundleQuery.GetMainBundleInfo(assetInfo);
if (bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromRemote)
return true;
else
return false;
} }
/// <summary> /// <summary>
@ -487,6 +467,28 @@ namespace YooAsset
string assetPath = _playModeImpl.ActiveManifest.TryMappingToAssetPath(location); string assetPath = _playModeImpl.ActiveManifest.TryMappingToAssetPath(location);
return string.IsNullOrEmpty(assetPath) == false; return string.IsNullOrEmpty(assetPath) == false;
} }
private bool IsNeedDownloadFromRemoteInternal(AssetInfo assetInfo)
{
if (assetInfo.IsInvalid)
{
YooLogger.Warning(assetInfo.Error);
return false;
}
BundleInfo bundleInfo = _bundleQuery.GetMainBundleInfo(assetInfo);
if (bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromRemote)
return true;
BundleInfo[] depends = _bundleQuery.GetDependBundleInfos(assetInfo);
foreach (var depend in depends)
{
if (depend.LoadMode == BundleInfo.ELoadMode.LoadFromRemote)
return true;
}
return false;
}
#endregion #endregion
#region 原生文件 #region 原生文件