Сделан сервис UI и заготовки панелек
This commit is contained in:
1 parent
6f2b063700
commit
ae76edb0d0
161 files changed
+70228
-6
No files matched your search
@@ -0,0 +1,11 @@
|
||||
namespace Code.UI
|
||||
{
|
||||
public interface IUIService
|
||||
{
|
||||
void EnablePanel();
|
||||
void DisablePanel();
|
||||
void SwitchPanelTo(UIPanel uiPanel);
|
||||
UIElement CurrentPanel { get; }
|
||||
LoadingPanel LoadingScreen { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5d5cb971e8da41a5885f37d1334ab26a
|
||||
timeCreated: 1761591248
|
||||
@@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.UI
|
||||
{
|
||||
public class LoadingPanel : UIElement
|
||||
{
|
||||
public void Hide()
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
public void Show()
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8b4a0cb6cea947c6b085269973968c12
|
||||
timeCreated: 1761594685
|
||||
@@ -0,0 +1,11 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Code.UI
|
||||
{
|
||||
public class MainMenuPanel : UIElement
|
||||
{
|
||||
public Button startButton;
|
||||
public Button exitButton;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3257edb60d20461a92f3e5dd2c4afee4
|
||||
timeCreated: 1761596135
|
||||
@@ -0,0 +1,8 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.UI
|
||||
{
|
||||
public class UIElement : MonoBehaviour
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b9af80648f8048e397791a856c682cce
|
||||
timeCreated: 1761590528
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Code.UI
|
||||
{
|
||||
public enum UIPanel
|
||||
{
|
||||
Loading,
|
||||
MainMenu,
|
||||
Gameplay
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d93383e80e824e0db25252a7863af280
|
||||
timeCreated: 1761578163
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 060152e7a2a2400f85c372c0b9f138a8
|
||||
timeCreated: 1761577528
|
||||
Reference in new issue
Block a user