Created
November 20, 2014 01:16
-
-
Save paulhayes/db82aeea3cd6495811a3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class SimpleFramePlayer : MonoBehaviour { | |
public float fps; | |
public Texture[] frames; | |
private float spf; | |
private float timeElapsed; | |
private int currentFrame; | |
void Start () { | |
spf = 1f/fps; | |
} | |
void Update () { | |
timeElapsed += Time.deltaTime; | |
if( timeElapsed >= spf ){ | |
timeElapsed -=spf; | |
currentFrame = ( currentFrame + 1 ) % frames.Length; | |
} | |
renderer.sharedMaterial.mainTexture = frames[currentFrame]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment