using System.Collections; using System.Collections.Generic; using UnityEngine; public class AnimatorLooper : MonoBehaviour { Animator anim; // Start is called before the first frame update void Start() { anim = GetComponentInChildren(); if(anim == null) { Destroy(this.gameObject); } } // Update is called once per frame void Update() { if(anim.GetCurrentAnimatorStateInfo(0).normalizedTime > 1) { anim.Play(anim.GetCurrentAnimatorStateInfo(0).fullPathHash, 0, 0); } } public void Toggle() { anim.speed = anim.speed == 1 ? 0 : 1; } }