Health/Assets/_VoiceAssistant/Scripts/Animations/TexturesSequenceFrame.cs

34 lines
704 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class TexturesSequenceFrame : MonoBehaviour
{
public Sprite[] sprites;
public Image image;
public float fps = 12;
float timer = 0;
int currentIndex = 0;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
float time = 1 / fps;
timer += Time.deltaTime;
if (timer >= time)
{
currentIndex += 1;
currentIndex %= sprites.Length;
timer -= time;
}
image.sprite = sprites[currentIndex];
}
}