2026-02-17 18:04:37 -08:00
|
|
|
using UnityEngine;
|
2026-02-18 01:32:13 -08:00
|
|
|
using UnityEngine.UIElements;
|
|
|
|
|
using UnityEngine.SceneManagement;
|
2026-02-17 18:04:37 -08:00
|
|
|
|
|
|
|
|
public class MainMenuController : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
private UIDocument _doc;
|
|
|
|
|
private Button _playButton;
|
|
|
|
|
private Button _settingsButton;
|
|
|
|
|
private Button _exitButton;
|
|
|
|
|
|
2026-02-18 01:32:13 -08:00
|
|
|
[Header("Sonidos del Menú")]
|
|
|
|
|
public AudioClip hoverSound;
|
|
|
|
|
public AudioClip clickSound;
|
|
|
|
|
private AudioSource _audioSource;
|
|
|
|
|
|
2026-02-17 18:04:37 -08:00
|
|
|
private void Awake()
|
|
|
|
|
{
|
|
|
|
|
_doc = GetComponent<UIDocument>();
|
|
|
|
|
var root = _doc.rootVisualElement;
|
|
|
|
|
|
2026-02-18 01:32:13 -08:00
|
|
|
_audioSource = gameObject.AddComponent<AudioSource>();
|
|
|
|
|
|
2026-02-17 18:04:37 -08:00
|
|
|
_playButton = root.Q<Button>("BtnPlay");
|
|
|
|
|
_settingsButton = root.Q<Button>("BtnSettings");
|
|
|
|
|
_exitButton = root.Q<Button>("BtnExit");
|
|
|
|
|
|
|
|
|
|
_playButton.clicked += OnPlayClicked;
|
|
|
|
|
_settingsButton.clicked += OnSettingsClicked;
|
|
|
|
|
_exitButton.clicked += OnExitClicked;
|
2026-02-18 01:32:13 -08:00
|
|
|
|
|
|
|
|
_playButton.RegisterCallback<PointerEnterEvent>(OnButtonHover);
|
|
|
|
|
_settingsButton.RegisterCallback<PointerEnterEvent>(OnButtonHover);
|
|
|
|
|
_exitButton.RegisterCallback<PointerEnterEvent>(OnButtonHover);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnButtonHover(PointerEnterEvent evt)
|
|
|
|
|
{
|
|
|
|
|
if (hoverSound != null) _audioSource.PlayOneShot(hoverSound);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PlayClickSound()
|
|
|
|
|
{
|
|
|
|
|
if (clickSound != null) _audioSource.PlayOneShot(clickSound);
|
2026-02-17 18:04:37 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnPlayClicked()
|
|
|
|
|
{
|
2026-02-18 01:32:13 -08:00
|
|
|
PlayClickSound();
|
2026-02-17 18:04:37 -08:00
|
|
|
Debug.Log("¡BWAAAH! Iniciando juego...");
|
|
|
|
|
// SceneManager.LoadScene("GameScene");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnSettingsClicked()
|
|
|
|
|
{
|
2026-02-18 01:32:13 -08:00
|
|
|
PlayClickSound();
|
2026-02-17 18:04:37 -08:00
|
|
|
Debug.Log("Abriendo ajustes...");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnExitClicked()
|
|
|
|
|
{
|
2026-02-18 01:32:13 -08:00
|
|
|
PlayClickSound();
|
2026-02-17 18:04:37 -08:00
|
|
|
Debug.Log("Saliendo...");
|
|
|
|
|
Application.Quit();
|
|
|
|
|
}
|
|
|
|
|
}
|