Ui button in unity when clicked opens pannel of buttons... When clicked again closes that button pannel. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Ui button in unity when clicked opens pannel of buttons... When clicked again closes that button pannel.

Any coders here who could help me with a really simple thing? . . I want to click on a ui button and when i click on this ui button i want a panel of buttons to appear (in upward direction) and when i re-click on that red button i want the entire panel and the rest of the three buttons to go back to the previous state... For this i have made 2 animations in unity 1 which expands the panel and the other one which makes the panel to go down (back to it's previous state)... I would really appreciate if someone could help me with the code.

13th Oct 2018, 8:47 PM
Zen
Zen - avatar
3 Answers
+ 3
You need a script that looks like that: bool appeared = false; public void onClick (){ if (appeared) { //start disappear anim } else { //start appear anim } appeared = !appeared } and then trigger the onClick func over the button
20th Oct 2018, 3:33 PM
Tim
Tim - avatar
+ 1
You might look for things like pane.isopen and visibility properties
24th Oct 2018, 2:17 AM
Uke Solomon
Uke Solomon - avatar
+ 1
You could try something with gameobject.activeSelf and if it's false you display it and vise versa
8th Nov 2018, 8:24 PM
TheTJO
TheTJO - avatar