50 lines
1.2 KiB
C#
50 lines
1.2 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using RR.Game2D.Core;
|
|
|
|
namespace RR.Common.UI
|
|
{
|
|
public class MainMenu : MonoBehaviour
|
|
{
|
|
[Header("Кнопки")]
|
|
[SerializeField] private Button newGameButton;
|
|
[SerializeField] private Button quitButton;
|
|
|
|
//private void Awake()
|
|
//{
|
|
// Bootstrap();
|
|
//}
|
|
|
|
private void Start()
|
|
{
|
|
Bootstrap();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Метод для загрузки элементов сцены.
|
|
/// Вешает события на кнопки
|
|
/// </summary>
|
|
public void Bootstrap()
|
|
{
|
|
if (newGameButton) newGameButton.onClick.AddListener(OnNewGame);
|
|
if (quitButton) quitButton.onClick.AddListener(OnQuit);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Метод начала новой игры
|
|
/// </summary>
|
|
private void OnNewGame()
|
|
{
|
|
|
|
GameManager.Instance.NewGame();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Метод выхода из игры
|
|
/// </summary>
|
|
private void OnQuit()
|
|
{
|
|
Application.Quit();
|
|
}
|
|
}
|
|
} |