mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-14 19:40:47 +00:00
update resource manager
新增初始化参数:WebGLForceSyncLoadAsset
This commit is contained in:
@@ -42,6 +42,11 @@ namespace YooAsset
|
||||
/// 同时加载Bundle文件的最大并发数
|
||||
/// </summary>
|
||||
public int BundleLoadingMaxConcurrency = int.MaxValue;
|
||||
|
||||
/// <summary>
|
||||
/// WebGL平台强制同步加载资源对象
|
||||
/// </summary>
|
||||
public bool WebGLForceSyncLoadAsset = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -260,8 +260,11 @@ namespace YooAsset
|
||||
StartOperation();
|
||||
}
|
||||
|
||||
IsWaitForAsyncComplete = true;
|
||||
InternalWaitForAsyncComplete();
|
||||
if (IsWaitForAsyncComplete == false)
|
||||
{
|
||||
IsWaitForAsyncComplete = true;
|
||||
InternalWaitForAsyncComplete();
|
||||
}
|
||||
}
|
||||
|
||||
#region 调试信息
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -321,6 +323,10 @@ namespace YooAsset
|
||||
{
|
||||
return BundleLoadingCounter >= _bundleLoadingMaxConcurrency;
|
||||
}
|
||||
internal bool WebGLForceSyncLoadAsset()
|
||||
{
|
||||
return _webGLForceSyncLoadAsset;
|
||||
}
|
||||
|
||||
private LoadBundleFileOperation CreateBundleFileLoaderInternal(BundleInfo bundleInfo)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user