mirror of
https://github.com/unity-atoms/unity-atoms.git
synced 2025-01-24 09:08:23 -05:00
28 lines
617 B
C#
28 lines
617 B
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace UnityAtoms
|
|
{
|
|
[AddComponentMenu("Unity Atoms/Hooks/On Button Click")]
|
|
[RequireComponent(typeof(Button))]
|
|
public sealed class OnButtonClickHook : VoidHook
|
|
{
|
|
private void Awake()
|
|
{
|
|
var button = GetComponent<Button>();
|
|
button.onClick.AddListener(OnClick);
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
var button = GetComponent<Button>();
|
|
button.onClick.RemoveListener(OnClick);
|
|
}
|
|
|
|
private void OnClick()
|
|
{
|
|
OnHook(new Void());
|
|
}
|
|
}
|
|
}
|