update
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class UIVirtualButton : MonoBehaviour, IPointerDownHandler, IPointerUpHandler, IPointerClickHandler
|
||||
{
|
||||
[System.Serializable]
|
||||
public class BoolEvent : UnityEvent<bool> { }
|
||||
[System.Serializable]
|
||||
public class Event : UnityEvent { }
|
||||
|
||||
[Header("Output")]
|
||||
public BoolEvent buttonStateOutputEvent;
|
||||
public Event buttonClickOutputEvent;
|
||||
|
||||
public void OnPointerDown(PointerEventData eventData)
|
||||
{
|
||||
OutputButtonStateValue(true);
|
||||
}
|
||||
|
||||
public void OnPointerUp(PointerEventData eventData)
|
||||
{
|
||||
OutputButtonStateValue(false);
|
||||
}
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
OutputButtonClickEvent();
|
||||
}
|
||||
|
||||
void OutputButtonStateValue(bool buttonState)
|
||||
{
|
||||
buttonStateOutputEvent.Invoke(buttonState);
|
||||
}
|
||||
|
||||
void OutputButtonClickEvent()
|
||||
{
|
||||
buttonClickOutputEvent.Invoke();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user