Фикс утечки памяти. Первой наверное...

This commit is contained in:
ThomasCharester committed 2025-11-03 12:54:45 +03:00
1 parent f940cbffe0
commit d861e06caf
1 file changed
+3 -1
+3 -1
View File
@@ -3,6 +3,7 @@ using System.Threading;
using Code.UI.Panels;
using Cysharp.Threading.Tasks;
using UnityEngine;
using UnityEngine.AddressableAssets;
using Object = UnityEngine.Object;
namespace Code.UI
@@ -13,6 +14,7 @@ namespace Code.UI
private IUIFactory _factory;
public UIElement CurrentPanel { get; private set; }
public LoadingScreen LoadingScreen { get; private set; }
public UIService(IUIFactory factory)
@@ -32,7 +34,7 @@ namespace Code.UI
{
if (!_canvas) await UniTask.WaitUntil(() => _canvas );
if(CurrentPanel) Object.Destroy(CurrentPanel.gameObject);
if(CurrentPanel) Addressables.ReleaseInstance(CurrentPanel.gameObject);//Object.Destroy(CurrentPanel.gameObject);
CurrentPanel = await _factory.CreatePanel(_canvas, uiPanel);