将下面的代码拖到Button上即可
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class ButtonHandler : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
{
public void OnPointerDown(PointerEventData eventData)
{
transform.localScale = Vector3.one * 1.2f;
}
public void OnPointerUp(PointerEventData eventData)
{
transform.localScale = Vector3.one;
}
}