using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; // 自动旋转 public class AutoRotate : MonoBehaviour,IPointerClickHandler { public GameObject rotateObject; // 旋转对象 public List sprites; // 0 旋转图片 1 停止图片 private bool isRotate; // 是否旋转 public void OnPointerClick(PointerEventData eventData) { // 获取椭圆运动组件 EllipticalMovement ellipticalMovement = rotateObject.GetComponent(); // 目前运动状态 isRotate = ellipticalMovement.isRun; // 改变运动状态 isRotate = !isRotate; ellipticalMovement.isRun =isRotate; StartCoroutine(ellipticalMovement.RotateAndPause()); // 改变图片 this.GetComponent().sprite = sprites[isRotate?1:0]; } }