Сделан сервис UI и заготовки панелек
This commit is contained in:
1 parent
159f530b51
commit
9cda28e03b
166 files changed
+70557
-9
No files matched your search
@@ -0,0 +1,32 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.UI
|
||||
{
|
||||
public class UIService : IUIService
|
||||
{
|
||||
private UIElement[] _uiPanelsPrefabs;
|
||||
private Canvas _canvas;
|
||||
public UIElement CurrentPanel { get; private set; }
|
||||
public LoadingPanel LoadingScreen { get; private set; }
|
||||
|
||||
public UIService(UIElement[] uiPanelsPrefabs, Canvas canvas)
|
||||
{
|
||||
_canvas = Object.Instantiate(canvas);
|
||||
Object.DontDestroyOnLoad(_canvas);
|
||||
|
||||
_uiPanelsPrefabs = uiPanelsPrefabs;
|
||||
|
||||
LoadingScreen = (LoadingPanel) Object.Instantiate(_uiPanelsPrefabs[(int)UIPanel.Loading], _canvas.transform);
|
||||
}
|
||||
|
||||
public void EnablePanel() => CurrentPanel.gameObject.SetActive(true);
|
||||
public void DisablePanel() => CurrentPanel.gameObject.SetActive(false);
|
||||
|
||||
public void SwitchPanelTo(UIPanel uiPanel)
|
||||
{
|
||||
Object.Destroy(CurrentPanel);
|
||||
|
||||
CurrentPanel = Object.Instantiate(_uiPanelsPrefabs[(int)uiPanel], _canvas.transform);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user