summaryrefslogtreecommitdiff
path: root/GameCode/HoverEvent.cs
blob: 6e9f33223894dfa60bbecea5a92de92799923ecb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using SoundImplementation;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;

public class HoverEvent : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler
{
	public UnityEvent enterEvent;

	public UnityEvent exitEvent;

	public bool isHovered;

	public bool isSelected;

	public void OnPointerEnter(PointerEventData eventData)
	{
		SoundPlayerStatic.Instance.PlayButtonHover();
		enterEvent.Invoke();
		isHovered = true;
	}

	public void OnPointerExit(PointerEventData eventData)
	{
		exitEvent.Invoke();
		isHovered = false;
	}

	private void Update()
	{
		isSelected = EventSystem.current.currentSelectedGameObject == base.gameObject;
	}

	private void OnDisable()
	{
		isHovered = false;
	}
}