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; } private void Start() { text = GetComponentInChildren(); initialTextPosition = text.transform.localPosition; } } }