using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class SpriteAnimation : MonoBehaviour { public float speed = 0.5f; public List sprites; public Image img; private int index = 0; private float timer = 0; void Update() { index %= sprites.Count; img.sprite = sprites[index]; timer += Time.deltaTime * 0.1f; if(timer >= speed) { index++; timer = 0; } } }