2022-02-23 14:53:01 +03:00
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.EventSystems;
|
|
|
|
using TMPro;
|
|
|
|
|
|
|
|
namespace UI
|
|
|
|
{
|
|
|
|
public class ButtonBehaviour : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
|
|
|
|
{
|
|
|
|
[SerializeField] private Vector2 offset = new Vector2(8, -8);
|
|
|
|
private TMP_Text text = null;
|
|
|
|
private Vector3 initialTextPosition = Vector3.zero;
|
|
|
|
|
|
|
|
public void OnPointerDown(PointerEventData eventData)
|
|
|
|
{
|
|
|
|
text.transform.localPosition = initialTextPosition + (Vector3)offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void OnPointerUp(PointerEventData eventData)
|
|
|
|
{
|
|
|
|
text.transform.localPosition = initialTextPosition;
|
2022-02-26 20:09:12 +03:00
|
|
|
UIManager.Instance.PlayClickSound();
|
2022-02-23 14:53:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
private void Start()
|
|
|
|
{
|
|
|
|
text = GetComponentInChildren<TMP_Text>();
|
|
|
|
initialTextPosition = text.transform.localPosition;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|