Add UI audio packs, fonts and update menus
Import two UI audio packs (Casual Game Sounds U6 and Free UI Click Sound Effects Pack) including dozens of .wav files, metadata, license/artwork and documentation. Add TextMesh Pro resources and new fonts (KOMIKAX and LiberationSans) and associated materials. Update MainMenu UI (MainMenu.uxml), its controller (MainMenuController.cs), panel settings asset and refresh MainMenu and SampleScene unity scenes to use the new assets.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements; // Necesario para UI Toolkit
|
||||
using UnityEngine.SceneManagement; // Para cambiar de escena
|
||||
using UnityEngine.UIElements;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class MainMenuController : MonoBehaviour
|
||||
{
|
||||
@@ -9,37 +9,57 @@ public class MainMenuController : MonoBehaviour
|
||||
private Button _settingsButton;
|
||||
private Button _exitButton;
|
||||
|
||||
[Header("Sonidos del Menú")]
|
||||
public AudioClip hoverSound;
|
||||
public AudioClip clickSound;
|
||||
private AudioSource _audioSource;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
// Obtenemos la referencia al documento
|
||||
_doc = GetComponent<UIDocument>();
|
||||
var root = _doc.rootVisualElement;
|
||||
|
||||
// Buscamos los botones por su nombre (el que pusimos en el UXML)
|
||||
_audioSource = gameObject.AddComponent<AudioSource>();
|
||||
|
||||
_playButton = root.Q<Button>("BtnPlay");
|
||||
_settingsButton = root.Q<Button>("BtnSettings");
|
||||
_exitButton = root.Q<Button>("BtnExit");
|
||||
|
||||
// Asignamos las funciones a los eventos Click
|
||||
_playButton.clicked += OnPlayClicked;
|
||||
_settingsButton.clicked += OnSettingsClicked;
|
||||
_exitButton.clicked += OnExitClicked;
|
||||
|
||||
_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);
|
||||
}
|
||||
|
||||
private void OnPlayClicked()
|
||||
{
|
||||
PlayClickSound();
|
||||
Debug.Log("¡BWAAAH! Iniciando juego...");
|
||||
// SceneManager.LoadScene("GameScene");
|
||||
}
|
||||
|
||||
private void OnSettingsClicked()
|
||||
{
|
||||
PlayClickSound();
|
||||
Debug.Log("Abriendo ajustes...");
|
||||
// Aquí podrías activar un panel superpuesto
|
||||
}
|
||||
|
||||
private void OnExitClicked()
|
||||
{
|
||||
PlayClickSound();
|
||||
Debug.Log("Saliendo...");
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user