Reviewed-on: #2 Co-authored-by: Jeremy Smitherman <Jeremysmitherman@gmail.com> Co-committed-by: Jeremy Smitherman <Jeremysmitherman@gmail.com>
34 lines
954 B
C#
34 lines
954 B
C#
using System;
|
|
using UnityEngine;
|
|
using UnityEngine.UIElements;
|
|
|
|
namespace UI
|
|
{
|
|
[RequireComponent(typeof(UIDocument))]
|
|
public class MainMenu : MonoBehaviour
|
|
{
|
|
public event Action OnStartGame;
|
|
public event Action OnExitGame;
|
|
|
|
private Button _startGameButton;
|
|
private Button _exitGameButton;
|
|
|
|
private void Awake()
|
|
{
|
|
_startGameButton = GetComponent<UIDocument>().rootVisualElement.Q<Button>("StartGameButton");
|
|
_exitGameButton = GetComponent<UIDocument>().rootVisualElement.Q<Button>("QuitGameButton");
|
|
_startGameButton.clicked += HandleStartGame;
|
|
_exitGameButton.clicked += () => OnExitGame?.Invoke();
|
|
}
|
|
private void OnDestroy()
|
|
{
|
|
_startGameButton.clicked -= HandleStartGame;
|
|
}
|
|
|
|
private void HandleStartGame()
|
|
{
|
|
OnStartGame?.Invoke();
|
|
}
|
|
}
|
|
}
|