46 lines
1.6 KiB
C#
46 lines
1.6 KiB
C#
using System;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace MedievalParty.MainMenu.MainSection
|
|
{
|
|
public class UI_MainSection: MonoBehaviour
|
|
{
|
|
public static UI_MainSection Instance { get; private set; }
|
|
|
|
public event EventHandler onNewGameTrigger;
|
|
public event EventHandler onContinueTrigger;
|
|
public event EventHandler onOptionTrigger;
|
|
public event EventHandler onQuitTrigger;
|
|
|
|
[SerializeField] private Button newGameButton;
|
|
[SerializeField] private Button continueButton;
|
|
[SerializeField] private Button optionButton;
|
|
[SerializeField] private Button quitButton;
|
|
|
|
private void Awake()
|
|
{
|
|
if (Instance)
|
|
{
|
|
Debug.LogWarning($"{typeof(UI_MainSection)} already exist! {transform}");
|
|
Destroy(gameObject);
|
|
return;
|
|
}
|
|
|
|
Instance = this;
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
newGameButton.onClick.AddListener(() => onNewGameTrigger?.Invoke(this, EventArgs.Empty));
|
|
continueButton.onClick.AddListener(() => onContinueTrigger?.Invoke(this, EventArgs.Empty));
|
|
optionButton.onClick.AddListener(() => onOptionTrigger?.Invoke(this, EventArgs.Empty));
|
|
quitButton.onClick.AddListener(() => onQuitTrigger?.Invoke(this, EventArgs.Empty));
|
|
|
|
MainMenuManager.Instance.onSectionChange +=
|
|
(_, section) => gameObject.SetActive(section == MainMenuManager.Section.Main);
|
|
|
|
gameObject.SetActive(false);
|
|
}
|
|
}
|
|
} |