Files
pgs/Assets/Scripts/UI/MenuItemController.cs

46 lines
1.1 KiB
C#
Raw Normal View History

2026-02-21 16:58:22 -08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class MenuItemController : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
[SerializeField] public Image image;
[SerializeField] public AudioSource audioSource;
[SerializeField] public AudioClip selectAudioClip;
public void OnPointerEnter(PointerEventData eventData) {
Debug.Log("Mouseover");
if (eventData.pointerCurrentRaycast.gameObject != null) {
image.color = Color.white;
audioSource.PlayOneShot(selectAudioClip);
}
}
public void OnPointerExit(PointerEventData eventData) {
Debug.Log("Mouseout");
Color c = image.color;
c.r = 0.9f;
c.g = 0.9f;
c.b = 0.9f;
image.color = c;
}
// Start is called before the first frame update
void Awake() {
Color c = image.color;
c.r = 0.9f;
c.g = 0.9f;
c.b = 0.9f;
image.color = c;
}
// Update is called once per frame
void Update()
{
}
}