Compare commits

...

2 Commits

Author SHA1 Message Date
何冠峰
0bde506aec feat #648 2025-10-09 19:10:26 +08:00
何冠峰
15005b3d30 sample : 程序集宏支持
YOO_MACRO_SUPPORT开启扩展代码
2025-10-09 19:07:03 +08:00
11 changed files with 36 additions and 5 deletions

View File

@@ -43,6 +43,11 @@ namespace YooAsset
/// </summary>
public int BundleLoadingMaxConcurrency = int.MaxValue;
/// <summary>
/// 当资源引用计数为零的时候自动释放资源包
/// </summary>
public bool AutoUnloadBundleWhenUnused = false;
/// <summary>
/// WebGL平台强制同步加载资源对象
/// </summary>

View File

@@ -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;
}
}

View File

@@ -308,6 +308,17 @@ namespace YooAsset
}
}
/// <summary>
/// 尝试卸载资源包
/// </summary>
public void TryUnloadBundle()
{
if (_resManager.AutoUnloadBundleWhenUnused)
{
_resManager.TryUnloadUnusedAsset(MainAssetInfo, 10);
}
}
/// <summary>
/// 结束流程
/// </summary>

View File

@@ -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;

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: bf6b81dffd4995e42a500ffc0025ec18
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,6 +1,6 @@
using System.Collections.Generic;
#if YOO_ASSET_EXPERIMENT
#if YOO_MACRO_SUPPORT
namespace YooAsset.Editor
{
public class MacroDefine

View File

@@ -5,7 +5,7 @@ using System.Text;
using System.Xml;
using UnityEditor;
#if YOO_ASSET_EXPERIMENT
#if YOO_MACRO_SUPPORT
namespace YooAsset.Editor
{
[InitializeOnLoad]

View File

@@ -6,7 +6,7 @@ using System.Xml;
using UnityEditor;
using UnityEngine;
#if YOO_ASSET_EXPERIMENT
#if YOO_MACRO_SUPPORT
namespace YooAsset.Editor.Experiment
{
[InitializeOnLoad]