Home Game Development unity – Playing animation on button press with a situation

unity – Playing animation on button press with a situation

0
unity – Playing animation on button press with a situation

[ad_1]

I need to do menu animation. In the animator, its comprise 2 animations. One is opening animation, the opposite is closing animation. I set the opening animation as default state and added situation between of them. The situation incorporates one parameter, it’s a bool kind parameter. I drag the script which controls they behaviours on gameobject and animator element, however when the opening animation performs and participant clicks the play button the parameter turns into true but it surely does not play.

 Animator canvasAnim;

 public Button lvlSelector;
 Button lvlSelector_A;

 // Use this for initialization
 void Start () {
     canvasAnim = GetComponent<Animator>();

     lvlSelector_A = lvlSelector.GetComponent<Button>();
     lvlSelector_A.onClick.AddListener(LevelSelector);

 }
 IEnumerator SlideLevelSelectMenu()
 {

     yield return new WaitForSeconds(1f);
     SceneManager.LoadScene("LevelSelectMenu");
 }

 void LevelSelector()
 {
     canvasAnim.SetBool("clickedclose", true);
     StartCoroutine(SlideLevelSelectMenu());
 }

Animator

Gameobject that keeps script component

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here