mirror of
https://github.com/LazyDuchess/OpenTS2.git
synced 2025-01-22 08:11:47 -05:00
UI Button: Play sound on button down
This commit is contained in:
parent
790a64d457
commit
561917e60d
1 changed files with 3 additions and 10 deletions
|
@ -17,7 +17,7 @@ namespace OpenTS2.UI
|
|||
public class UIButtonComponent : UIComponent, IPointerEnterHandler, IPointerExitHandler, IPointerDownHandler, IPointerUpHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// Triggers when this button is clicked. Boolean argument specifies whether it was a double click.
|
||||
/// Triggers when this button is clicked.
|
||||
/// </summary>
|
||||
public Action OnClick;
|
||||
public bool GreyedOut = false;
|
||||
|
@ -87,6 +87,7 @@ namespace OpenTS2.UI
|
|||
{
|
||||
if (eventData.button != PointerEventData.InputButton.Left && eventData.button != PointerEventData.InputButton.Right)
|
||||
return;
|
||||
AudioManager.Instance.PlayUISound(ClickSound);
|
||||
_held = true;
|
||||
}
|
||||
|
||||
|
@ -95,16 +96,8 @@ namespace OpenTS2.UI
|
|||
if (eventData.button != PointerEventData.InputButton.Left && eventData.button != PointerEventData.InputButton.Right)
|
||||
return;
|
||||
if (_held && _hovering)
|
||||
{
|
||||
Click();
|
||||
}
|
||||
OnClick?.Invoke();
|
||||
_held = false;
|
||||
}
|
||||
|
||||
void Click()
|
||||
{
|
||||
AudioManager.Instance.PlayUISound(ClickSound);
|
||||
OnClick?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue