You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.3 KiB
52 lines
1.3 KiB
using System; |
|
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
using UnityEngine.Events; |
|
using UnityEngine.EventSystems; |
|
using UnityEngine.Serialization; |
|
|
|
public class ButtonPress : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IPointerClickHandler |
|
{ |
|
[Serializable] |
|
public class ButtonEvent : UnityEvent { } |
|
|
|
[FormerlySerializedAs("onPressDown")] |
|
[SerializeField] |
|
private ButtonEvent m_OnPressDown = new ButtonEvent(); |
|
public ButtonEvent onPressDown |
|
{ |
|
get { return m_OnPressDown; } |
|
set { m_OnPressDown = value; } |
|
} |
|
public void OnPointerEnter(PointerEventData eventData) |
|
{ |
|
m_OnPressDown.Invoke(); |
|
} |
|
|
|
[FormerlySerializedAs("onPressUp")] |
|
[SerializeField] |
|
private ButtonEvent m_OnPressUp = new ButtonEvent(); |
|
public ButtonEvent OnPressUp |
|
{ |
|
get { return m_OnPressUp; } |
|
set { m_OnPressUp = value; } |
|
} |
|
public void OnPointerExit(PointerEventData eventData) |
|
{ |
|
m_OnPressUp.Invoke(); |
|
} |
|
|
|
[FormerlySerializedAs("onClick")] |
|
[SerializeField] |
|
private ButtonEvent m_OnClick = new ButtonEvent(); |
|
public ButtonEvent OnClick |
|
{ |
|
get { return m_OnClick; } |
|
set { m_OnClick = value; } |
|
} |
|
public void OnPointerClick(PointerEventData eventData) |
|
{ |
|
OnClick.Invoke(); |
|
} |
|
}
|
|
|