UI Button to display canvas then hide when other button is pushed.
Push Game options Button - Displays options Canvas in Empty area.
Once another button is pushed Controller setup Game Options should hide. …
I hope you all understand what im getting too.
i need help doing this im so lost. I know there is onclick but once another button is pressed it stays up along with the other button.
Yes, you’ll have to turn off whatever panels are open. You either have a reference to the panel that you can call or when you open a panel, you create a reference at that point and then just close it. Depending on how many parts you have to options depends on how you’ll want to do it.
If for example you have a gameobject array and have 5 parts in it, you could just loop through and set them all to setActive(false) and then turn on the one panel you need on. This works pretty well for small groups. The other option is if you have a large amount, then when you open a panel, you assign it to a GameObject variable, then you know it has a value and you can just set that to SetActive(false) Just check that it isn’t null
ok i got all the canvas off that im using for a buttons. But when i select them to setactive(FALSE) Button on the Onlick it wont turn off when clicking another button. The canvas will stay or wont show up at all.
Image is canvas one and Full shade Grey box is Canvas two. I disable the setactive on button one and it wont display. But when they are both checked it works. … im lost as of right now lol. like i said i want it so when you click on second button first canvas hides or goes away.
Show some code of how you’re doing this. And don’t forget code tags.
Basic idea though should be. This will handle it fine if you don’t have a lot of panels. There are additional ways and I did this quick by hand, so yeah, just to give you an idea.
public GameObject[] optionPanels; //Drag and drop values in the inspector. These are your canvases, or however you have your option boxes setup.
public void openPanel(GameObject selectPanel)
{
foreach(GameObject opPanel in optionPanels)
{
opPanel.SetActive(false);
}
selectPanel.SetActive(true);
}
They pop up witch is nice. But when i click on the second button the 1st canvas stays up… I want it to hide after clicking the next button …
its really throwing me off. Learning this little as i go but im just lost ATM lol… I thank everyone for the help as well