From 712b303858e3078ba301f3296831f3dcc6172725 Mon Sep 17 00:00:00 2001 From: "ALIENJACK\\alien" Date: Tue, 19 Aug 2025 17:13:54 +0800 Subject: [PATCH] =?UTF-8?q?versionflow=20autorelease=E6=9C=BA=E5=88=B6?= =?UTF-8?q?=E4=BC=98=E5=8C=96,=E4=B8=8B=E4=B8=80=E5=B8=A7=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E5=8D=B8=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/VersionFlow/Runtime/BundleManager.cs | 28 ++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/Assets/VersionFlow/Runtime/BundleManager.cs b/Assets/VersionFlow/Runtime/BundleManager.cs index 60a2bd6..0577347 100644 --- a/Assets/VersionFlow/Runtime/BundleManager.cs +++ b/Assets/VersionFlow/Runtime/BundleManager.cs @@ -34,6 +34,8 @@ namespace VersionFlow.Runtime internal BundleManager(BundleManifest local, BundleManifest remote) { + VersionFlowX.BeginCoroutine(AutoReleaseCoroutine()); + //初始化BundleManager Stopwatch sw = Stopwatch.StartNew(); @@ -88,7 +90,24 @@ namespace VersionFlow.Runtime VersionFlowX.Log($"创建资源清单耗时:{sw.Elapsed.Milliseconds}ms"); } - internal BundleManager() { } + internal BundleManager() + { + VersionFlowX.BeginCoroutine(AutoReleaseCoroutine()); + } + + IEnumerator AutoReleaseCoroutine() + { + while (true) + { + if (VersionFlowX.Setting.AutoReleaseBundle && m_unloadDirty) + { + m_unloadDirty = false; + TryUnLoadBundles(); + } + + yield return null; + } + } internal ABEntity GetEntityByAssetPath(string assetPath) { @@ -351,6 +370,7 @@ namespace VersionFlow.Runtime return request; } + bool m_unloadDirty = false; public void ReleaseAsset(ref T asset) where T : UnityEngine.Object { if (!VersionFlowX.Setting.Enable) @@ -366,8 +386,10 @@ namespace VersionFlow.Runtime asset = null; - if (VersionFlowX.Setting.AutoReleaseBundle) - TryUnLoadBundles(); + if (!m_unloadDirty && VersionFlowX.Setting.AutoReleaseBundle) + { + m_unloadDirty = true; + } } } public void ReleaseAsset(IList assetList) where T : UnityEngine.Object