46 lines
1.1 KiB
C#
46 lines
1.1 KiB
C#
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()
|
|
{
|
|
|
|
}
|
|
}
|