I have a broblem with boolean (Unity)

Jul 17 2018 12:01 PM
I have 3 canvas and 3 buttons that make each panel visible
 
Button 1 ---> Canvas 1, Button 2 ---> Canvas 2, Button 3 ---> Canvas 3
 
I want only one canvas visible every time, so i want every click on the button 1 to: activate canvas 1 and close canvas 2 and 3 (same for buttons 2,3)
 
this is my code (i dont know why but it doesnt work can you help me?):
(Only one bool works every time) 
 
public CanvasGroup CgUp;
public CanvasGroup CgGe;
public CanvasGroup CgMa;
private bool isVisibleUp;
private bool isVisibleGe;
private bool isVisibleMa;
// Canvas1 Visibility
public void ToggleVisibilityUp ()
{
if (isVisibleUp == false)
{
CgUp.alpha = 1;
CgGe.alpha = 0;
CgMa.alpha. = 0;
CgUp.interactable = true;
CgGe.interactable = false;
CgMa.interactable = false;
isVisibleUp = true;
isVisibleGe = false;
isVisibleMa = false;
}
else
{
CgUp.alpha = 0;
CgUp.interactable = false;
isVisibleUp = false;
}
}
// Canvas2 Visibility
public void ToggleVisibilityGe ()
{
if (isVisibleGe == false)
{
CgUp.alpha = 0;
CgGe.alpha = 1;
CgMa.alpha. = 0;
CgUp.interactable = false;
CgGe.interactable = true;
CgMa.interactable = false;
isVisibleUp = false;
isVisibleGe = true;
isVisibleMa = false;
}
else
{
CgGe.alpha = 0;
CgGe.interactable = false;
isVisibleGe = false;
}
}
// Canvas3 Visibility
public void ToggleVisibilityMa ()
{
if (isVisibleMa == false)
{
CgUp.alpha = 0;
CgGe.alpha = 0;
CgMa.alpha. = 1;
CgUp.interactable = false;
CgGe.interactable = false;
CgMa.interactable = true;
isVisibleUp = false;
isVisibleGe = false;
isVisibleMa = true;
}
else
{
CgMa.alpha. = 0;
CgMa.interactable = false;
isVisibleMa = false;
}
}
}

Answers (3)