- Home /
How to play two animations with one UI button?
So I have a panel, and I have a button. I want it so that when I click the button the panel slides in from the left, and when I click the button again, it slides back out of frame. I already have two animations for the panel sliding in and out. How can I accomplish this?
Answer by HypoSlyper · Dec 26, 2021 at 06:50 AM
You have to add a bool that stores whether the panel is open or closed. When the button is clicked, you check the bool. If the panel is closed, you play the 'in' animation and when it's open, you play the 'out' animation.
Your answer
Follow this Question
Related Questions
Why are my UI elements hidden behind the background? 3 Answers
Button onClick events will not be triggered 1 Answer
Two buttons behaving entirely differently (despite similar logic in code)? 1 Answer
Highlighted buttons stay highlighted when I deactivate a canvas. No way to unhighlight them. 1 Answer
What is the code to load a panel that is not a buildIndex scene? 1 Answer