I’ve two animations(created with Unity animation and animator) in my gui texture. I want to play it with toggle(Toggle code works perfectly fine).The problem is the default animation clip of animator of this gui texture keeps on playing everytime.The second animation clip “ahint2” doesn’t play. Please suggest
function Check(){
India.gameObject.SetActive(true);
anim1.SetTrigger("ahint1");
India.gameObject.animation.Play("ahint1");
yield WaitForSeconds(India.animation["ahint1"].clip.length);cut = true;
}
function Wait(){
if(cut){
Debug.Log("enter");
anim1.SetTrigger("ahint2");
India.gameObject.animation.Play("ahint2");
yield WaitForSeconds(India.animation["ahint2"].clip.length);}
}
From your script it seems that you’re using both Animation and Animator components (the animation.Play part refers to Animation, and anim.SetTrigger(“…”) refers to Animator). I would first suggest that you stick with either Animation or Animator and avoid using both at the same time since as far as I know they are two systems that handles animation in different ways, and having both of them working at the same time it’s possible to get unpredictable behaviour.
Other than that, an obvious suggestions: check if you’ve turned off “Play Automatically” on your Animation component. If you’ve unticked that box already but your animation is still not playing the way you want, then maybe you can post your complete animation control script and maybe a screenshot of your animator controller set up so we can better understand your situation.