How can I toggle visibility off for multiple panels when I toggle visibility on for one?
Hello. Just like the title says, I am trying to basically manipulate my menus to where only one is visible and interactive at a time. Basically, when a menu opens, it opens full screen so it is the only thing that the player sees. I have been using this:
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;
public class Visibility: MonoBehaviour { public CanvasGroup CG;
private bool isVisible;
//Clicking toggles between visible and invisible
public void ToggleVisibility()
{
if (isVisible == false)
{
CG.alpha = 1;
CG.interactable = true;
isVisible = true;
}
else
{
CG.alpha = 0;
CG.interactable = false;
isVisible = false;
}
}
I have been assigning this to the button that corresponds to the menu item that I want open. However, now that I have multiple menu items unless the player goes in and closes out each menu item before he clicks a new one they just pop on top or under the current display depending on where they sit in the canvas. Is there an easier or more efficient way to do this?