В инфраструктуре начался сущий кошмар

This commit is contained in:
ThomasCharester committed 2025-11-14 22:21:51 +03:00
1 parent 346dc97fef
commit e67fea2051
51 files changed
+659 -140

No files matched your search

+3 -1
View File
@@ -1,13 +1,15 @@
using System;
using Code.UI.Panels;
using Cysharp.Threading.Tasks;
namespace Code.UI
{
public interface IUIService
{
void SwitchPanelTo(UIPanel uiPanel, Action callback = null);
UniTask AsyncSwitchPanelTo(UIPanel uiPanel);
UIElement CurrentPanel { get; }
LoadingScreen LoadingScreen { get; }
void Initialize(LoadingScreen loadingScreen);
UniTask Initialize(LoadingScreen loadingScreen);
}
}
+12 -3
View File
@@ -12,7 +12,8 @@ namespace Code.UI
{
private Canvas _canvas;
private IUIFactory _factory;
public UIElement CurrentPanel { get; private set; }
public LoadingScreen LoadingScreen { get; private set; }
@@ -22,7 +23,7 @@ namespace Code.UI
_factory = factory;
}
public async void Initialize(LoadingScreen loadingScreen)
public async UniTask Initialize(LoadingScreen loadingScreen)
{
LoadingScreen = loadingScreen;
LoadingScreen.Show();
@@ -30,9 +31,17 @@ namespace Code.UI
_canvas = await _factory.CreateCanvas();
}
public async UniTask AsyncSwitchPanelTo(UIPanel uiPanel)
{
// if (!_canvas) await UniTask.WaitUntil(() => _canvas );
if(CurrentPanel) Addressables.ReleaseInstance(CurrentPanel.gameObject);//Object.Destroy(CurrentPanel.gameObject);
CurrentPanel = await _factory.CreatePanel(_canvas, uiPanel);
}
public async void SwitchPanelTo(UIPanel uiPanel, Action callback = null)
{
if (!_canvas) await UniTask.WaitUntil(() => _canvas );
// if (!_canvas) await UniTask.WaitUntil(() => _canvas );
if(CurrentPanel) Addressables.ReleaseInstance(CurrentPanel.gameObject);//Object.Destroy(CurrentPanel.gameObject);