mirror of https://github.com/tuyoogame/YooAsset
[optimize]使用Unity Pool对List回收使用
parent
4c619778c3
commit
6e67b21ee3
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine.Pool;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
|
@ -9,7 +10,7 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 依赖的资源包加载器列表
|
/// 依赖的资源包加载器列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal readonly List<BundleLoaderBase> DependList;
|
internal List<BundleLoaderBase> DependList { private set; get; }
|
||||||
|
|
||||||
|
|
||||||
public DependAssetBundles(List<BundleLoaderBase> dpendList)
|
public DependAssetBundles(List<BundleLoaderBase> dpendList)
|
||||||
|
@ -92,6 +93,8 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
loader.Release();
|
loader.Release();
|
||||||
}
|
}
|
||||||
|
ListPool<BundleLoaderBase>.Release(DependList);
|
||||||
|
DependList = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.Pool;
|
||||||
using UnityEngine.SceneManagement;
|
using UnityEngine.SceneManagement;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
|
@ -107,7 +108,7 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
// 卸载依赖资源包加载器
|
// 卸载依赖资源包加载器
|
||||||
string[] dependBundleNames = _bundleQuery.GetDependBundleNames(assetInfo);
|
var dependBundleNames = _bundleQuery.GetDependBundleNames(assetInfo);
|
||||||
foreach (var dependBundleName in dependBundleNames)
|
foreach (var dependBundleName in dependBundleNames)
|
||||||
{
|
{
|
||||||
var dependLoader = TryGetAssetBundleLoader(dependBundleName);
|
var dependLoader = TryGetAssetBundleLoader(dependBundleName);
|
||||||
|
@ -122,6 +123,7 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ListPool<string>.Release(dependBundleNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -392,13 +394,14 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
internal List<BundleLoaderBase> CreateDependAssetBundleLoaders(AssetInfo assetInfo)
|
internal List<BundleLoaderBase> CreateDependAssetBundleLoaders(AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
BundleInfo[] depends = _bundleQuery.GetDependBundleInfos(assetInfo);
|
List<BundleInfo> depends = _bundleQuery.GetDependBundleInfos(assetInfo);
|
||||||
List<BundleLoaderBase> result = new List<BundleLoaderBase>(depends.Length);
|
List<BundleLoaderBase> result = ListPool<BundleLoaderBase>.Get();
|
||||||
foreach (var bundleInfo in depends)
|
foreach (var bundleInfo in depends)
|
||||||
{
|
{
|
||||||
BundleLoaderBase dependLoader = CreateAssetBundleLoaderInternal(bundleInfo);
|
BundleLoaderBase dependLoader = CreateAssetBundleLoaderInternal(bundleInfo);
|
||||||
result.Add(dependLoader);
|
result.Add(dependLoader);
|
||||||
}
|
}
|
||||||
|
ListPool<BundleInfo>.Release(depends);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
internal void RemoveBundleProviders(List<ProviderBase> removeList)
|
internal void RemoveBundleProviders(List<ProviderBase> removeList)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.Pool;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
|
@ -186,6 +187,7 @@ namespace YooAsset
|
||||||
var bundleInfo = CreateUnpackInfo(assist, packageBundle);
|
var bundleInfo = CreateUnpackInfo(assist, packageBundle);
|
||||||
result.Add(bundleInfo);
|
result.Add(bundleInfo);
|
||||||
}
|
}
|
||||||
|
ListPool<PackageBundle>.Release(unpackList);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
private static BundleInfo CreateUnpackInfo(ResourceAssist assist, PackageBundle packageBundle)
|
private static BundleInfo CreateUnpackInfo(ResourceAssist assist, PackageBundle packageBundle)
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
internal interface IBundleQuery
|
internal interface IBundleQuery
|
||||||
|
@ -11,7 +13,7 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取依赖的资源包信息集合
|
/// 获取依赖的资源包信息集合
|
||||||
/// </summary>
|
/// </summary>
|
||||||
BundleInfo[] GetDependBundleInfos(AssetInfo assetPath);
|
List<BundleInfo> GetDependBundleInfos(AssetInfo assetPath);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取主资源包名称
|
/// 获取主资源包名称
|
||||||
|
@ -21,7 +23,7 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取依赖的资源包名称集合
|
/// 获取依赖的资源包名称集合
|
||||||
/// </summary>
|
/// </summary>
|
||||||
string[] GetDependBundleNames(AssetInfo assetInfo);
|
List<string> GetDependBundleNames(AssetInfo assetInfo);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清单是否有效
|
/// 清单是否有效
|
||||||
|
|
|
@ -3,6 +3,7 @@ using System.IO;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine.Pool;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
|
@ -146,10 +147,10 @@ namespace YooAsset
|
||||||
/// 获取资源依赖列表
|
/// 获取资源依赖列表
|
||||||
/// 注意:传入的资源路径一定合法有效!
|
/// 注意:传入的资源路径一定合法有效!
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public PackageBundle[] GetAllDependencies(string assetPath)
|
public List<PackageBundle> GetAllDependencies(string assetPath)
|
||||||
{
|
{
|
||||||
var packageBundle = GetMainPackageBundle(assetPath);
|
var packageBundle = GetMainPackageBundle(assetPath);
|
||||||
List<PackageBundle> result = new List<PackageBundle>(packageBundle.DependIDs.Length);
|
var result = ListPool<PackageBundle>.Get();
|
||||||
foreach (var dependID in packageBundle.DependIDs)
|
foreach (var dependID in packageBundle.DependIDs)
|
||||||
{
|
{
|
||||||
if (dependID >= 0 && dependID < BundleList.Count)
|
if (dependID >= 0 && dependID < BundleList.Count)
|
||||||
|
@ -162,7 +163,7 @@ namespace YooAsset
|
||||||
throw new Exception($"Invalid bundle id : {dependID} Asset path : {assetPath}");
|
throw new Exception($"Invalid bundle id : {dependID} Asset path : {assetPath}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result.ToArray();
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine.Pool;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
|
@ -114,20 +115,21 @@ namespace YooAsset
|
||||||
var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath);
|
var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath);
|
||||||
return CreateBundleInfo(packageBundle, assetInfo);
|
return CreateBundleInfo(packageBundle, assetInfo);
|
||||||
}
|
}
|
||||||
BundleInfo[] IBundleQuery.GetDependBundleInfos(AssetInfo assetInfo)
|
List<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 !");
|
||||||
|
|
||||||
// 注意:如果清单里未找到资源包会抛出异常!
|
// 注意:如果清单里未找到资源包会抛出异常!
|
||||||
var depends = _activeManifest.GetAllDependencies(assetInfo.AssetPath);
|
List<PackageBundle> depends = _activeManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||||
List<BundleInfo> result = new List<BundleInfo>(depends.Length);
|
List<BundleInfo> result = ListPool<BundleInfo>.Get();
|
||||||
foreach (var packageBundle in depends)
|
foreach (var packageBundle in depends)
|
||||||
{
|
{
|
||||||
BundleInfo bundleInfo = CreateBundleInfo(packageBundle, assetInfo);
|
BundleInfo bundleInfo = CreateBundleInfo(packageBundle, assetInfo);
|
||||||
result.Add(bundleInfo);
|
result.Add(bundleInfo);
|
||||||
}
|
}
|
||||||
return result.ToArray();
|
ListPool<PackageBundle>.Release(depends);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
string IBundleQuery.GetMainBundleName(AssetInfo assetInfo)
|
string IBundleQuery.GetMainBundleName(AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
|
@ -138,19 +140,20 @@ namespace YooAsset
|
||||||
var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath);
|
var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath);
|
||||||
return packageBundle.BundleName;
|
return packageBundle.BundleName;
|
||||||
}
|
}
|
||||||
string[] IBundleQuery.GetDependBundleNames(AssetInfo assetInfo)
|
List<string> IBundleQuery.GetDependBundleNames(AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
if (assetInfo.IsInvalid)
|
if (assetInfo.IsInvalid)
|
||||||
throw new Exception("Should never get here !");
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
// 注意:如果清单里未找到资源包会抛出异常!
|
// 注意:如果清单里未找到资源包会抛出异常!
|
||||||
var depends = _activeManifest.GetAllDependencies(assetInfo.AssetPath);
|
List<PackageBundle> depends = _activeManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||||
List<string> result = new List<string>(depends.Length);
|
List<string> result = ListPool<string>.Get();
|
||||||
foreach (var packageBundle in depends)
|
foreach (var packageBundle in depends)
|
||||||
{
|
{
|
||||||
result.Add(packageBundle.BundleName);
|
result.Add(packageBundle.BundleName);
|
||||||
}
|
}
|
||||||
return result.ToArray();
|
ListPool<PackageBundle>.Release(depends);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
bool IBundleQuery.ManifestValid()
|
bool IBundleQuery.ManifestValid()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine.Pool;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
|
@ -60,6 +61,7 @@ namespace YooAsset
|
||||||
var bundleInfo = ConvertToDownloadInfo(packageBundle);
|
var bundleInfo = ConvertToDownloadInfo(packageBundle);
|
||||||
result.Add(bundleInfo);
|
result.Add(bundleInfo);
|
||||||
}
|
}
|
||||||
|
ListPool<PackageBundle>.Release(downloadList);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
private BundleInfo ConvertToDownloadInfo(PackageBundle packageBundle)
|
private BundleInfo ConvertToDownloadInfo(PackageBundle packageBundle)
|
||||||
|
@ -133,7 +135,7 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
public List<BundleInfo> GetDownloadListByAll(PackageManifest manifest)
|
public List<BundleInfo> GetDownloadListByAll(PackageManifest manifest)
|
||||||
{
|
{
|
||||||
List<PackageBundle> downloadList = new List<PackageBundle>(1000);
|
List<PackageBundle> downloadList = ListPool<PackageBundle>.Get();
|
||||||
foreach (var packageBundle in manifest.BundleList)
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
{
|
{
|
||||||
// 忽略分发文件
|
// 忽略分发文件
|
||||||
|
@ -162,7 +164,7 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
public List<BundleInfo> GetDownloadListByTags(PackageManifest manifest, string[] tags)
|
public List<BundleInfo> GetDownloadListByTags(PackageManifest manifest, string[] tags)
|
||||||
{
|
{
|
||||||
List<PackageBundle> downloadList = new List<PackageBundle>(1000);
|
List<PackageBundle> downloadList = ListPool<PackageBundle>.Get();
|
||||||
foreach (var packageBundle in manifest.BundleList)
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
{
|
{
|
||||||
// 忽略分发文件
|
// 忽略分发文件
|
||||||
|
@ -219,15 +221,16 @@ namespace YooAsset
|
||||||
checkList.Add(mainBundle);
|
checkList.Add(mainBundle);
|
||||||
|
|
||||||
// 注意:如果清单里未找到资源包会抛出异常!
|
// 注意:如果清单里未找到资源包会抛出异常!
|
||||||
PackageBundle[] dependBundles = manifest.GetAllDependencies(assetInfo.AssetPath);
|
List<PackageBundle> dependBundles = manifest.GetAllDependencies(assetInfo.AssetPath);
|
||||||
foreach (var dependBundle in dependBundles)
|
foreach (var dependBundle in dependBundles)
|
||||||
{
|
{
|
||||||
if (checkList.Contains(dependBundle) == false)
|
if (checkList.Contains(dependBundle) == false)
|
||||||
checkList.Add(dependBundle);
|
checkList.Add(dependBundle);
|
||||||
}
|
}
|
||||||
|
ListPool<PackageBundle>.Release(dependBundles);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<PackageBundle> downloadList = new List<PackageBundle>(1000);
|
List<PackageBundle> downloadList = ListPool<PackageBundle>.Get();
|
||||||
foreach (var packageBundle in checkList)
|
foreach (var packageBundle in checkList)
|
||||||
{
|
{
|
||||||
// 忽略分发文件
|
// 忽略分发文件
|
||||||
|
@ -256,7 +259,7 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
private List<BundleInfo> GetUnpackListByAll(PackageManifest manifest)
|
private List<BundleInfo> GetUnpackListByAll(PackageManifest manifest)
|
||||||
{
|
{
|
||||||
List<PackageBundle> downloadList = new List<PackageBundle>(1000);
|
List<PackageBundle> downloadList = ListPool<PackageBundle>.Get();
|
||||||
foreach (var packageBundle in manifest.BundleList)
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
{
|
{
|
||||||
// 忽略缓存文件
|
// 忽略缓存文件
|
||||||
|
@ -280,7 +283,7 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
private List<BundleInfo> GetUnpackListByTags(PackageManifest manifest, string[] tags)
|
private List<BundleInfo> GetUnpackListByTags(PackageManifest manifest, string[] tags)
|
||||||
{
|
{
|
||||||
List<PackageBundle> downloadList = new List<PackageBundle>(1000);
|
List<PackageBundle> downloadList = ListPool<PackageBundle>.Get();
|
||||||
foreach (var packageBundle in manifest.BundleList)
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
{
|
{
|
||||||
// 忽略缓存文件
|
// 忽略缓存文件
|
||||||
|
@ -370,20 +373,21 @@ namespace YooAsset
|
||||||
var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath);
|
var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath);
|
||||||
return CreateBundleInfo(packageBundle);
|
return CreateBundleInfo(packageBundle);
|
||||||
}
|
}
|
||||||
BundleInfo[] IBundleQuery.GetDependBundleInfos(AssetInfo assetInfo)
|
List<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 !");
|
||||||
|
|
||||||
// 注意:如果清单里未找到资源包会抛出异常!
|
// 注意:如果清单里未找到资源包会抛出异常!
|
||||||
var depends = _activeManifest.GetAllDependencies(assetInfo.AssetPath);
|
List<PackageBundle> depends = _activeManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||||
List<BundleInfo> result = new List<BundleInfo>(depends.Length);
|
List<BundleInfo> result = ListPool<BundleInfo>.Get();
|
||||||
foreach (var packageBundle in depends)
|
foreach (var packageBundle in depends)
|
||||||
{
|
{
|
||||||
BundleInfo bundleInfo = CreateBundleInfo(packageBundle);
|
BundleInfo bundleInfo = CreateBundleInfo(packageBundle);
|
||||||
result.Add(bundleInfo);
|
result.Add(bundleInfo);
|
||||||
}
|
}
|
||||||
return result.ToArray();
|
ListPool<PackageBundle>.Release(depends);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
string IBundleQuery.GetMainBundleName(AssetInfo assetInfo)
|
string IBundleQuery.GetMainBundleName(AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
|
@ -394,19 +398,20 @@ namespace YooAsset
|
||||||
var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath);
|
var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath);
|
||||||
return packageBundle.BundleName;
|
return packageBundle.BundleName;
|
||||||
}
|
}
|
||||||
string[] IBundleQuery.GetDependBundleNames(AssetInfo assetInfo)
|
List<string> IBundleQuery.GetDependBundleNames(AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
if (assetInfo.IsInvalid)
|
if (assetInfo.IsInvalid)
|
||||||
throw new Exception("Should never get here !");
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
// 注意:如果清单里未找到资源包会抛出异常!
|
// 注意:如果清单里未找到资源包会抛出异常!
|
||||||
var depends = _activeManifest.GetAllDependencies(assetInfo.AssetPath);
|
List<PackageBundle> depends = _activeManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||||
List<string> result = new List<string>(depends.Length);
|
List<string> result = ListPool<string>.Get();
|
||||||
foreach (var packageBundle in depends)
|
foreach (var packageBundle in depends)
|
||||||
{
|
{
|
||||||
result.Add(packageBundle.BundleName);
|
result.Add(packageBundle.BundleName);
|
||||||
}
|
}
|
||||||
return result.ToArray();
|
ListPool<PackageBundle>.Release(depends);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
bool IBundleQuery.ManifestValid()
|
bool IBundleQuery.ManifestValid()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine.Pool;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
|
@ -103,7 +104,7 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
private List<BundleInfo> GetUnpackListByAll(PackageManifest manifest)
|
private List<BundleInfo> GetUnpackListByAll(PackageManifest manifest)
|
||||||
{
|
{
|
||||||
List<PackageBundle> downloadList = new List<PackageBundle>(1000);
|
List<PackageBundle> downloadList = ListPool<PackageBundle>.Get();
|
||||||
foreach (var packageBundle in manifest.BundleList)
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
{
|
{
|
||||||
// 忽略缓存文件
|
// 忽略缓存文件
|
||||||
|
@ -124,7 +125,7 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
private List<BundleInfo> GetUnpackListByTags(PackageManifest manifest, string[] tags)
|
private List<BundleInfo> GetUnpackListByTags(PackageManifest manifest, string[] tags)
|
||||||
{
|
{
|
||||||
List<PackageBundle> downloadList = new List<PackageBundle>(1000);
|
List<PackageBundle> downloadList = ListPool<PackageBundle>.Get();
|
||||||
foreach (var packageBundle in manifest.BundleList)
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
{
|
{
|
||||||
// 忽略缓存文件
|
// 忽略缓存文件
|
||||||
|
@ -199,20 +200,21 @@ namespace YooAsset
|
||||||
var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath);
|
var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath);
|
||||||
return CreateBundleInfo(packageBundle);
|
return CreateBundleInfo(packageBundle);
|
||||||
}
|
}
|
||||||
BundleInfo[] IBundleQuery.GetDependBundleInfos(AssetInfo assetInfo)
|
List<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 !");
|
||||||
|
|
||||||
// 注意:如果清单里未找到资源包会抛出异常!
|
// 注意:如果清单里未找到资源包会抛出异常!
|
||||||
var depends = _activeManifest.GetAllDependencies(assetInfo.AssetPath);
|
List<PackageBundle> depends = _activeManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||||
List<BundleInfo> result = new List<BundleInfo>(depends.Length);
|
List<BundleInfo> result = ListPool<BundleInfo>.Get();
|
||||||
foreach (var packageBundle in depends)
|
foreach (var packageBundle in depends)
|
||||||
{
|
{
|
||||||
BundleInfo bundleInfo = CreateBundleInfo(packageBundle);
|
BundleInfo bundleInfo = CreateBundleInfo(packageBundle);
|
||||||
result.Add(bundleInfo);
|
result.Add(bundleInfo);
|
||||||
}
|
}
|
||||||
return result.ToArray();
|
ListPool<PackageBundle>.Release(depends);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
string IBundleQuery.GetMainBundleName(AssetInfo assetInfo)
|
string IBundleQuery.GetMainBundleName(AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
|
@ -223,19 +225,20 @@ namespace YooAsset
|
||||||
var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath);
|
var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath);
|
||||||
return packageBundle.BundleName;
|
return packageBundle.BundleName;
|
||||||
}
|
}
|
||||||
string[] IBundleQuery.GetDependBundleNames(AssetInfo assetInfo)
|
List<string> IBundleQuery.GetDependBundleNames(AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
if (assetInfo.IsInvalid)
|
if (assetInfo.IsInvalid)
|
||||||
throw new Exception("Should never get here !");
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
// 注意:如果清单里未找到资源包会抛出异常!
|
// 注意:如果清单里未找到资源包会抛出异常!
|
||||||
var depends = _activeManifest.GetAllDependencies(assetInfo.AssetPath);
|
List<PackageBundle> depends = _activeManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||||
List<string> result = new List<string>(depends.Length);
|
List<string> result = ListPool<string>.Get();
|
||||||
foreach (var packageBundle in depends)
|
foreach (var packageBundle in depends)
|
||||||
{
|
{
|
||||||
result.Add(packageBundle.BundleName);
|
result.Add(packageBundle.BundleName);
|
||||||
}
|
}
|
||||||
return result.ToArray();
|
ListPool<PackageBundle>.Release(depends);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
bool IBundleQuery.ManifestValid()
|
bool IBundleQuery.ManifestValid()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine.Pool;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
|
@ -61,6 +62,7 @@ namespace YooAsset
|
||||||
var bundleInfo = ConvertToDownloadInfo(packageBundle);
|
var bundleInfo = ConvertToDownloadInfo(packageBundle);
|
||||||
result.Add(bundleInfo);
|
result.Add(bundleInfo);
|
||||||
}
|
}
|
||||||
|
ListPool<PackageBundle>.Release(downloadList);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +132,7 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
public List<BundleInfo> GetDownloadListByAll(PackageManifest manifest)
|
public List<BundleInfo> GetDownloadListByAll(PackageManifest manifest)
|
||||||
{
|
{
|
||||||
List<PackageBundle> downloadList = new List<PackageBundle>(1000);
|
List<PackageBundle> downloadList = ListPool<PackageBundle>.Get();
|
||||||
foreach (var packageBundle in manifest.BundleList)
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
{
|
{
|
||||||
// 忽略缓存文件
|
// 忽略缓存文件
|
||||||
|
@ -155,7 +157,7 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
public List<BundleInfo> GetDownloadListByTags(PackageManifest manifest, string[] tags)
|
public List<BundleInfo> GetDownloadListByTags(PackageManifest manifest, string[] tags)
|
||||||
{
|
{
|
||||||
List<PackageBundle> downloadList = new List<PackageBundle>(1000);
|
List<PackageBundle> downloadList = ListPool<PackageBundle>.Get();
|
||||||
foreach (var packageBundle in manifest.BundleList)
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
{
|
{
|
||||||
// 忽略缓存文件
|
// 忽略缓存文件
|
||||||
|
@ -208,15 +210,16 @@ namespace YooAsset
|
||||||
checkList.Add(mainBundle);
|
checkList.Add(mainBundle);
|
||||||
|
|
||||||
// 注意:如果清单里未找到资源包会抛出异常!
|
// 注意:如果清单里未找到资源包会抛出异常!
|
||||||
PackageBundle[] dependBundles = manifest.GetAllDependencies(assetInfo.AssetPath);
|
List<PackageBundle> dependBundles = manifest.GetAllDependencies(assetInfo.AssetPath);
|
||||||
foreach (var dependBundle in dependBundles)
|
foreach (var dependBundle in dependBundles)
|
||||||
{
|
{
|
||||||
if (checkList.Contains(dependBundle) == false)
|
if (checkList.Contains(dependBundle) == false)
|
||||||
checkList.Add(dependBundle);
|
checkList.Add(dependBundle);
|
||||||
}
|
}
|
||||||
|
ListPool<PackageBundle>.Release(dependBundles);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<PackageBundle> downloadList = new List<PackageBundle>(1000);
|
List<PackageBundle> downloadList = ListPool<PackageBundle>.Get();
|
||||||
foreach (var packageBundle in checkList)
|
foreach (var packageBundle in checkList)
|
||||||
{
|
{
|
||||||
// 忽略缓存文件
|
// 忽略缓存文件
|
||||||
|
@ -273,20 +276,21 @@ namespace YooAsset
|
||||||
var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath);
|
var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath);
|
||||||
return CreateBundleInfo(packageBundle);
|
return CreateBundleInfo(packageBundle);
|
||||||
}
|
}
|
||||||
BundleInfo[] IBundleQuery.GetDependBundleInfos(AssetInfo assetInfo)
|
List<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 !");
|
||||||
|
|
||||||
// 注意:如果清单里未找到资源包会抛出异常!
|
// 注意:如果清单里未找到资源包会抛出异常!
|
||||||
var depends = _activeManifest.GetAllDependencies(assetInfo.AssetPath);
|
List<PackageBundle> depends = _activeManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||||
List<BundleInfo> result = new List<BundleInfo>(depends.Length);
|
List<BundleInfo> result = ListPool<BundleInfo>.Get();
|
||||||
foreach (var packageBundle in depends)
|
foreach (var packageBundle in depends)
|
||||||
{
|
{
|
||||||
BundleInfo bundleInfo = CreateBundleInfo(packageBundle);
|
BundleInfo bundleInfo = CreateBundleInfo(packageBundle);
|
||||||
result.Add(bundleInfo);
|
result.Add(bundleInfo);
|
||||||
}
|
}
|
||||||
return result.ToArray();
|
ListPool<PackageBundle>.Release(depends);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
string IBundleQuery.GetMainBundleName(AssetInfo assetInfo)
|
string IBundleQuery.GetMainBundleName(AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
|
@ -297,19 +301,20 @@ namespace YooAsset
|
||||||
var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath);
|
var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath);
|
||||||
return packageBundle.BundleName;
|
return packageBundle.BundleName;
|
||||||
}
|
}
|
||||||
string[] IBundleQuery.GetDependBundleNames(AssetInfo assetInfo)
|
List<string> IBundleQuery.GetDependBundleNames(AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
if (assetInfo.IsInvalid)
|
if (assetInfo.IsInvalid)
|
||||||
throw new Exception("Should never get here !");
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
// 注意:如果清单里未找到资源包会抛出异常!
|
// 注意:如果清单里未找到资源包会抛出异常!
|
||||||
var depends = _activeManifest.GetAllDependencies(assetInfo.AssetPath);
|
List<PackageBundle> depends = _activeManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||||
List<string> result = new List<string>(depends.Length);
|
List<string> result = ListPool<string>.Get();
|
||||||
foreach (var packageBundle in depends)
|
foreach (var packageBundle in depends)
|
||||||
{
|
{
|
||||||
result.Add(packageBundle.BundleName);
|
result.Add(packageBundle.BundleName);
|
||||||
}
|
}
|
||||||
return result.ToArray();
|
ListPool<PackageBundle>.Release(depends);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
bool IBundleQuery.ManifestValid()
|
bool IBundleQuery.ManifestValid()
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,6 +3,7 @@ using System.Diagnostics;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine.SceneManagement;
|
using UnityEngine.SceneManagement;
|
||||||
|
using UnityEngine.Pool;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
|
@ -534,13 +535,13 @@ namespace YooAsset
|
||||||
if (bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromRemote)
|
if (bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromRemote)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
BundleInfo[] depends = _bundleQuery.GetDependBundleInfos(assetInfo);
|
List<BundleInfo> depends = _bundleQuery.GetDependBundleInfos(assetInfo);
|
||||||
foreach (var depend in depends)
|
foreach (var depend in depends)
|
||||||
{
|
{
|
||||||
if (depend.LoadMode == BundleInfo.ELoadMode.LoadFromRemote)
|
if (depend.LoadMode == BundleInfo.ELoadMode.LoadFromRemote)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
ListPool<BundleInfo>.Release(depends);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
Loading…
Reference in New Issue