- Home /
Move UI panel
Hello.
I have an UI panel that has a animation going up on Y. The animation is activated when we click the button that is on the panel. Works fine. Now I want to click on it again to bring the panel back down. I've thought on reversing the animation on second click, fourth click, and so on... but via script I'm not finding a way to do it. Is there a better way? And how?
Thanks in advance
Answer by Jaz30 · May 09, 2018 at 11:58 PM
What do you mean click on it again? If you can click the button again even though the panel goes up, you can use this snippet code:
//First declare a bool that will check if the panel is up or down
bool panelChecker;
//Use can do your animation here
void Update()
{
if(panelChecker)
{
//Animate Panel Up
}
else
{
//Animate Panel Down
}
}
//You can trigger this method to make panel animate up and down.
public void AnimatePanel()
{
if(panelChecker)
{
panelChecker = false;
}
else
{
panelChecker = true;
}
}
Hope it helps.
Your answer
Follow this Question
Related Questions
Menu problem 1 Answer
How do you make an UI animation longer than one second? 3 Answers
Animating a Panel,Animating a panel 1 Answer
How to create animations that can be edited with scripts in runtime? 1 Answer
AvatarIKGoal argument problem 0 Answers