mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
Update YooAsset 2.3.8 -> 2.3.12
This commit is contained in:
@@ -14,7 +14,7 @@ namespace YooAsset
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly ResourceManager _resourceManager;
|
||||
private readonly ResourceManager _resManager;
|
||||
private readonly List<ProviderOperation> _providers = new List<ProviderOperation>(100);
|
||||
private readonly List<ProviderOperation> _removeList = new List<ProviderOperation>(100);
|
||||
private FSLoadBundleOperation _loadBundleOp;
|
||||
@@ -53,7 +53,7 @@ namespace YooAsset
|
||||
|
||||
internal LoadBundleFileOperation(ResourceManager resourceManager, BundleInfo bundleInfo)
|
||||
{
|
||||
_resourceManager = resourceManager;
|
||||
_resManager = resourceManager;
|
||||
LoadBundleInfo = bundleInfo;
|
||||
}
|
||||
internal override void InternalStart()
|
||||
@@ -73,7 +73,7 @@ namespace YooAsset
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_resourceManager.BundleLoadingIsBusy())
|
||||
if (_resManager.BundleLoadingIsBusy())
|
||||
return;
|
||||
_steps = ESteps.LoadBundleFile;
|
||||
}
|
||||
@@ -83,7 +83,7 @@ namespace YooAsset
|
||||
{
|
||||
if (_loadBundleOp == null)
|
||||
{
|
||||
_resourceManager.BundleLoadingCounter++;
|
||||
_resManager.BundleLoadingCounter++;
|
||||
_loadBundleOp = LoadBundleInfo.LoadBundleFile();
|
||||
_loadBundleOp.StartOperation();
|
||||
AddChildOperation(_loadBundleOp);
|
||||
@@ -121,7 +121,7 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
// 统计计数减少
|
||||
_resourceManager.BundleLoadingCounter--;
|
||||
_resManager.BundleLoadingCounter--;
|
||||
}
|
||||
}
|
||||
internal override void InternalWaitForAsyncComplete()
|
||||
@@ -191,7 +191,7 @@ namespace YooAsset
|
||||
{
|
||||
foreach (var bundleID in LoadBundleInfo.Bundle.ReferenceBundleIDs)
|
||||
{
|
||||
if (_resourceManager.CheckBundleDestroyed(bundleID) == false)
|
||||
if (_resManager.CheckBundleDestroyed(bundleID) == false)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -233,7 +233,7 @@ namespace YooAsset
|
||||
// 移除资源提供者
|
||||
if (_removeList.Count > 0)
|
||||
{
|
||||
_resourceManager.RemoveBundleProviders(_removeList);
|
||||
_resManager.RemoveBundleProviders(_removeList);
|
||||
_removeList.Clear();
|
||||
}
|
||||
}
|
||||
|
@@ -15,6 +15,11 @@ namespace YooAsset
|
||||
_loadAllAssetsOp = BundleResultObject.LoadAllAssetsAsync(MainAssetInfo);
|
||||
_loadAllAssetsOp.StartOperation();
|
||||
AddChildOperation(_loadAllAssetsOp);
|
||||
|
||||
#if UNITY_WEBGL
|
||||
if (_resManager.WebGLForceSyncLoadAsset())
|
||||
_loadAllAssetsOp.WaitForAsyncComplete();
|
||||
#endif
|
||||
}
|
||||
|
||||
if (IsWaitForAsyncComplete)
|
||||
|
@@ -15,6 +15,11 @@ namespace YooAsset
|
||||
_loadAssetOp = BundleResultObject.LoadAssetAsync(MainAssetInfo);
|
||||
_loadAssetOp.StartOperation();
|
||||
AddChildOperation(_loadAssetOp);
|
||||
|
||||
#if UNITY_WEBGL
|
||||
if (_resManager.WebGLForceSyncLoadAsset())
|
||||
_loadAssetOp.WaitForAsyncComplete();
|
||||
#endif
|
||||
}
|
||||
|
||||
if (IsWaitForAsyncComplete)
|
||||
|
@@ -68,13 +68,14 @@ namespace YooAsset
|
||||
|
||||
|
||||
private ESteps _steps = ESteps.None;
|
||||
protected readonly ResourceManager _resManager;
|
||||
private readonly LoadBundleFileOperation _mainBundleLoader;
|
||||
private readonly List<LoadBundleFileOperation> _bundleLoaders = new List<LoadBundleFileOperation>(10);
|
||||
private readonly HashSet<HandleBase> _handles = new HashSet<HandleBase>();
|
||||
|
||||
|
||||
public ProviderOperation(ResourceManager manager, string providerGUID, AssetInfo assetInfo)
|
||||
{
|
||||
_resManager = manager;
|
||||
ProviderGUID = providerGUID;
|
||||
MainAssetInfo = assetInfo;
|
||||
|
||||
|
@@ -15,6 +15,11 @@ namespace YooAsset
|
||||
_loadSubAssetsOp = BundleResultObject.LoadSubAssetsAsync(MainAssetInfo);
|
||||
_loadSubAssetsOp.StartOperation();
|
||||
AddChildOperation(_loadSubAssetsOp);
|
||||
|
||||
#if UNITY_WEBGL
|
||||
if (_resManager.WebGLForceSyncLoadAsset())
|
||||
_loadSubAssetsOp.WaitForAsyncComplete();
|
||||
#endif
|
||||
}
|
||||
|
||||
if (IsWaitForAsyncComplete)
|
||||
|
@@ -15,6 +15,7 @@ namespace YooAsset
|
||||
private long _sceneCreateIndex = 0;
|
||||
private IBundleQuery _bundleQuery;
|
||||
private int _bundleLoadingMaxConcurrency;
|
||||
private bool _webGLForceSyncLoadAsset;
|
||||
|
||||
/// <summary>
|
||||
/// 所属包裹
|
||||
@@ -43,6 +44,7 @@ namespace YooAsset
|
||||
public void Initialize(InitializeParameters parameters, IBundleQuery bundleServices)
|
||||
{
|
||||
_bundleLoadingMaxConcurrency = parameters.BundleLoadingMaxConcurrency;
|
||||
_webGLForceSyncLoadAsset = parameters.WebGLForceSyncLoadAsset;
|
||||
_bundleQuery = bundleServices;
|
||||
SceneManager.sceneUnloaded += OnSceneUnloaded;
|
||||
}
|
||||
@@ -58,7 +60,7 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 尝试卸载指定资源的资源包(包括依赖资源)
|
||||
/// </summary>
|
||||
public void TryUnloadUnusedAsset(AssetInfo assetInfo)
|
||||
public void TryUnloadUnusedAsset(AssetInfo assetInfo, int loopCount)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
{
|
||||
@@ -66,34 +68,39 @@ namespace YooAsset
|
||||
return;
|
||||
}
|
||||
|
||||
// 卸载主资源包加载器
|
||||
string mainBundleName = _bundleQuery.GetMainBundleName(assetInfo);
|
||||
var mainLoader = TryGetBundleFileLoader(mainBundleName);
|
||||
if (mainLoader != null)
|
||||
while (loopCount > 0)
|
||||
{
|
||||
mainLoader.TryDestroyProviders();
|
||||
if (mainLoader.CanDestroyLoader())
|
||||
{
|
||||
string bundleName = mainLoader.LoadBundleInfo.Bundle.BundleName;
|
||||
mainLoader.DestroyLoader();
|
||||
LoaderDic.Remove(bundleName);
|
||||
}
|
||||
}
|
||||
loopCount--;
|
||||
|
||||
// 卸载依赖资源包加载器
|
||||
string[] dependBundleNames = _bundleQuery.GetDependBundleNames(assetInfo);
|
||||
foreach (var dependBundleName in dependBundleNames)
|
||||
{
|
||||
var dependLoader = TryGetBundleFileLoader(dependBundleName);
|
||||
if (dependLoader != null)
|
||||
// 卸载主资源包加载器
|
||||
string mainBundleName = _bundleQuery.GetMainBundleName(assetInfo);
|
||||
var mainLoader = TryGetBundleFileLoader(mainBundleName);
|
||||
if (mainLoader != null)
|
||||
{
|
||||
if (dependLoader.CanDestroyLoader())
|
||||
mainLoader.TryDestroyProviders();
|
||||
if (mainLoader.CanDestroyLoader())
|
||||
{
|
||||
string bundleName = dependLoader.LoadBundleInfo.Bundle.BundleName;
|
||||
dependLoader.DestroyLoader();
|
||||
string bundleName = mainLoader.LoadBundleInfo.Bundle.BundleName;
|
||||
mainLoader.DestroyLoader();
|
||||
LoaderDic.Remove(bundleName);
|
||||
}
|
||||
}
|
||||
|
||||
// 卸载依赖资源包加载器
|
||||
string[] dependBundleNames = _bundleQuery.GetDependBundleNames(assetInfo);
|
||||
foreach (var dependBundleName in dependBundleNames)
|
||||
{
|
||||
var dependLoader = TryGetBundleFileLoader(dependBundleName);
|
||||
if (dependLoader != null)
|
||||
{
|
||||
if (dependLoader.CanDestroyLoader())
|
||||
{
|
||||
string bundleName = dependLoader.LoadBundleInfo.Bundle.BundleName;
|
||||
dependLoader.DestroyLoader();
|
||||
LoaderDic.Remove(bundleName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -321,6 +328,10 @@ namespace YooAsset
|
||||
{
|
||||
return BundleLoadingCounter >= _bundleLoadingMaxConcurrency;
|
||||
}
|
||||
internal bool WebGLForceSyncLoadAsset()
|
||||
{
|
||||
return _webGLForceSyncLoadAsset;
|
||||
}
|
||||
|
||||
private LoadBundleFileOperation CreateBundleFileLoaderInternal(BundleInfo bundleInfo)
|
||||
{
|
||||
|
Reference in New Issue
Block a user