mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-17 05:10:12 +00:00
feat #648
This commit is contained in:
@@ -43,6 +43,11 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public int BundleLoadingMaxConcurrency = int.MaxValue;
|
||||
|
||||
/// <summary>
|
||||
/// 当资源引用计数为零的时候自动释放资源包
|
||||
/// </summary>
|
||||
public bool AutoUnloadBundleWhenUnused = false;
|
||||
|
||||
/// <summary>
|
||||
/// WebGL平台强制同步加载资源对象
|
||||
/// </summary>
|
||||
|
||||
@@ -23,6 +23,11 @@ namespace YooAsset
|
||||
if (IsValidWithWarning == false)
|
||||
return;
|
||||
Provider.ReleaseHandle(this);
|
||||
|
||||
// 主动卸载零引用的资源包
|
||||
if (Provider.RefCount == 0)
|
||||
Provider.TryUnloadBundle();
|
||||
|
||||
Provider = null;
|
||||
}
|
||||
|
||||
@@ -146,11 +151,11 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public System.Threading.Tasks.Task Task
|
||||
{
|
||||
get
|
||||
get
|
||||
{
|
||||
if (IsValidWithWarning == false)
|
||||
return null;
|
||||
return Provider.Task;
|
||||
return Provider.Task;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -308,6 +308,17 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 尝试卸载资源包
|
||||
/// </summary>
|
||||
public void TryUnloadBundle()
|
||||
{
|
||||
if (_resManager.AutoUnloadBundleWhenUnused)
|
||||
{
|
||||
_resManager.TryUnloadUnusedAsset(MainAssetInfo, 10);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 结束流程
|
||||
/// </summary>
|
||||
|
||||
@@ -17,6 +17,7 @@ namespace YooAsset
|
||||
private int _bundleLoadingMaxConcurrency;
|
||||
|
||||
// 开发者配置选项
|
||||
public bool AutoUnloadBundleWhenUnused { private set; get; }
|
||||
public bool WebGLForceSyncLoadAsset { private set; get; }
|
||||
public bool UseWeakReferenceHandle { private set; get; }
|
||||
|
||||
@@ -47,6 +48,7 @@ namespace YooAsset
|
||||
public void Initialize(InitializeParameters parameters, IBundleQuery bundleServices)
|
||||
{
|
||||
_bundleLoadingMaxConcurrency = parameters.BundleLoadingMaxConcurrency;
|
||||
AutoUnloadBundleWhenUnused = parameters.AutoUnloadBundleWhenUnused;
|
||||
WebGLForceSyncLoadAsset = parameters.WebGLForceSyncLoadAsset;
|
||||
UseWeakReferenceHandle = parameters.UseWeakReferenceHandle;
|
||||
_bundleQuery = bundleServices;
|
||||
|
||||
Reference in New Issue
Block a user