using DG.Tweening; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class RowerAnimation : PFUIPanel { List sprites; Image image; public bool isFinish = false; protected override void Awake() { base.Awake(); sprites = new List(); for (int i = 1; i <= 30; i++) { sprites.Add(Resources.Load($"Images/Rower/序列帧/划船机{i.ToString("0000")}")); } image = transform.GetComponent(); } protected override void Start() { //time = 0; } int index = 0; //float time = 0; public override void Show() { //base.Show(); //index = 0; ////time = 0; //StartCoroutine(Animation()); } public void StartAnimation() { index = 0; isFinish = false; StartCoroutine(Animation()); } IEnumerator Animation() { yield return new WaitForEndOfFrame(); for (int i = 0; i < 15; i++) { image.sprite = sprites[i]; yield return new WaitForSeconds(0.02f); } for (int i = 15; i < 30; i++) { image.sprite = sprites[i]; yield return new WaitForSeconds(0.04f); } } void Update() { //time += Time.deltaTime; //if (time < 0.03) //{ // return; //} //time = 0; //if (index % 79 == 0) //{ // index = 0; //} //image.sprite = sprites[index]; //index++; } public override void Close() { StopCoroutine(Animation()); base.Close(); } }