29 lines
		
	
	
		
			637 B
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			29 lines
		
	
	
		
			637 B
		
	
	
	
		
			C#
		
	
	
	
|  | using System.Collections; | |||
|  | using System.Collections.Generic; | |||
|  | using UnityEngine; | |||
|  | using UnityEngine.UI; | |||
|  | using UnityEngine.EventSystems; | |||
|  | using DG.Tweening; | |||
|  | 
 | |||
|  | [RequireComponent(typeof(Animator))] | |||
|  | public class UIButtonAni : MonoBehaviour, IPointerDownHandler, IPointerUpHandler | |||
|  | { | |||
|  |     private Animator anim; | |||
|  | 
 | |||
|  |     private void Start() | |||
|  |     { | |||
|  |         anim = this.GetComponent<Animator>(); | |||
|  |     } | |||
|  | 
 | |||
|  |     //点击事件 | |||
|  |     public void OnPointerDown(PointerEventData eventData) | |||
|  |     { | |||
|  |         anim.SetTrigger("Pressed"); | |||
|  |     } | |||
|  | 
 | |||
|  |     //松开事件 | |||
|  |     public void OnPointerUp(PointerEventData eventData) | |||
|  |     { | |||
|  |         anim.SetTrigger("Normal"); | |||
|  |     } | |||
|  | } |