using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class VoxelAnimation : MonoBehaviour {

	#region variables
	private MeshFilter _mesh;

	[SerializeField]
	private Mesh[] _meshes;

	private int _index = 0;
	private float _fps = 5f;
	#endregion


	#region events
	void Awake () {

		_mesh = GetComponent <MeshFilter> ();
		
	}

	void Start () {
		
		StartCoroutine (Animate ());

	}
	#endregion


	#region coroutines
	IEnumerator Animate () {

		while (true) {

			yield return new WaitForSeconds (1 / _fps);
			_index = (_index + 1) % _meshes.Length;

			_mesh.sharedMesh = _meshes[_index];
			
		}
		
	}
	#endregion
	
}
