TouhouLS/TouhouStation/Assets/RealCode/Animations/SimpleAnimationLoop.cs

21 lines
468 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SimpleAnimationLoop : MonoBehaviour {
private new SpriteRenderer renderer;
public Sprite[] sprites;
public float frameTime = 0.75f;
private void Awake() {
renderer = GetComponent<SpriteRenderer>();
}
private void Update() {
var frameindex = Mathf.FloorToInt(Time.time / frameTime);
renderer.sprite = sprites[frameindex % sprites.Length];
}
}