mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-26 02:30:18 +00:00
Compare commits
2 Commits
4caf733ac6
...
0bde506aec
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0bde506aec | ||
|
|
15005b3d30 |
@@ -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;
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bf6b81dffd4995e42a500ffc0025ec18
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
#if YOO_ASSET_EXPERIMENT
|
||||
#if YOO_MACRO_SUPPORT
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class MacroDefine
|
||||
@@ -5,7 +5,7 @@ using System.Text;
|
||||
using System.Xml;
|
||||
using UnityEditor;
|
||||
|
||||
#if YOO_ASSET_EXPERIMENT
|
||||
#if YOO_MACRO_SUPPORT
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[InitializeOnLoad]
|
||||
@@ -6,7 +6,7 @@ using System.Xml;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
#if YOO_ASSET_EXPERIMENT
|
||||
#if YOO_MACRO_SUPPORT
|
||||
namespace YooAsset.Editor.Experiment
|
||||
{
|
||||
[InitializeOnLoad]
|
||||
Reference in New Issue
Block a user