projectEli/Assets/NeoFPS/Samples/Shared/UserInterface/MultiInputWidgets/MultiInputButton.cs
2022-11-06 20:28:33 -05:00

39 lines
689 B
C#

using System;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
namespace NeoFPS.Samples
{
public class MultiInputButton : MultiInputWidget, ISubmitHandler, IPointerClickHandler
{
[SerializeField] private UnityEvent m_OnClick = new UnityEvent();
public UnityEvent onClick
{
get { return m_OnClick; }
}
public void OnPointerClick (PointerEventData eventData)
{
Press ();
}
public void OnSubmit (BaseEventData eventData)
{
Press ();
}
private void Press ()
{
if (IsInteractable ())
{
m_OnClick.Invoke ();
PlayAudio (MenuAudio.ClickValid);
}
else
PlayAudio (MenuAudio.ClickInvalid);
}
}
}