using System.Collections; using System.Collections.Generic; using UnityEngine; public class virusAnimationScript : MonoBehaviour { private Animator anim; public float delay = 0f; private float time; //IEnumerator ExecuteAfterTime(float time) //{ // yield return new WaitForSeconds(time); // // Code to execute after the delay // gameObject.SetActive(false); // yield break; //} // Start is called before the first frame update void Start() { Destroy(gameObject, this.GetComponent<Animator>().GetCurrentAnimatorStateInfo(0).length + delay); //time = GetComponent<Animator>().GetCurrentAnimatorStateInfo(0).length;//anim.runtimeAnimatorController.animationClips[0].length; //StartCoroutine(ExecuteAfterTime(time + delay)); } // Update is called once per frame void Update() { } }