Hey,
I’m trying to code some panels so that when a button is pressed it enabled the panels, and when the button is pressed again it disables the panels. (Later on I will also close the panels and open new ones, if a different button is pressed.
Right now though, I successfully managed to script the panels to open OnClick but they don’t close on click. When I try to code in the panels closing, OnClick will simply do nothing. I’ve tried using the inspector too but I get the same problem.
Here is the code currently;
[B]void disablePanel()[/B]
{
woodPanelUI.SetActive(false);
woodWorkUI.SetActive(false);
}
[B]void enablePanel()[/B]
{
woodWorkUI.SetActive(true);
woodPanelUI.SetActive(true);
}
and here is the code when I try to do an if statement to determine whether the panels are open or not.
void disablePanel()
{
if enablePanel() = true;
woodPanelUI.SetActive(false);
woodWorkUI.SetActive(false);
}
void enablePanel()
{
woodWorkUI.SetActive(true);
woodPanelUI.SetActive(true);
}
Using the if statement is just throwing numerous errors in my face about parenthesis expected and overload exceptions and explicit casting. So when I attempt to fix the errors it just brings up the same errors.
I also tried a different piece of code all together; one I much preferred:
void switchCanvas(bool disable)
{
if (!disable)
woodPanelUI.SetActive(false);
woodWorkUI.SetActive(false); [B]*[/B]
else
woodWorkUI.SetActive(true);
woodPanelUI.SetActive(true);
}
The only problem with this piece of code, is that for some reason it expects a } after the 3rd line of code (see the * marked.)
Any help would be great, and I’d much rather use the second code for speed in future development process of the project.