2020-08-22 05:29:00 +00:00
|
|
|
|
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>();
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-22 23:43:30 +00:00
|
|
|
|
public void Update() {
|
2020-08-22 05:29:00 +00:00
|
|
|
|
var frameindex = Mathf.FloorToInt(Time.time / frameTime);
|
|
|
|
|
renderer.sprite = sprites[frameindex % sprites.Length];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|