Files
pgs/Assets/Effects/Sprite Effects/Animation_seq.cs

24 lines
546 B
C#
Raw Normal View History

2026-02-21 16:58:22 -08:00
using UnityEngine;
using System.Collections;
public class Animation_seq: MonoBehaviour
{
public float fps = 24.0f;
public Texture2D[] frames;
private int frameIndex;
private MeshRenderer rendererMy;
void Start()
{
rendererMy = GetComponent<MeshRenderer>();
NextFrame();
InvokeRepeating("NextFrame", 1 / fps, 1 / fps);
}
void NextFrame()
{
rendererMy.sharedMaterial.SetTexture("_MainTex", frames[frameIndex]);
frameIndex = (frameIndex + 0001) % frames.Length;
}
}