How do I set up a bool, that has three questions instead of two? I have a main menu, a pause menu, and the player UI. Normally if main menu is showing then it’s true while pause would be false, and vice versa. So how would I go about it with all three? I am still pretty new to scripting, and the bools always get me. Maybe I over think it. Just need explained steps so I can understand it more fully. The MenuTransitions is the script I am trying to get the bool to work, seeing as I do not quite understand bools anyway, its been hard. The ShowPanelsMenu is the script I am calling from. If one of the three is true then the two other should be false, and I need this for each one: the menu, the pausemenu, and the playerUI. Am I doing the bool right?
Menu Transitions
using UnityEngine;
using System.Collections;
public class MenuTransitions : MonoBehaviour {
public bool mainMenu;
public bool pauseMenu;
public bool playerUI;
private ShowPanelsMenu showPanelsMenu;
void Awake ()
{
showPanelsMenu = GetComponent<ShowPanelsMenu>();
}
public void MainMenu ()
{
if (mainMenu = true) {
showPanelsMenu.ShowMainMenuPanel ();
showPanelsMenu.HidePausePanel ();
showPanelsMenu.HidePlayerUIPanel ();
}
else
{
if (mainMenu = false)
{
showPanelsMenu.HideMainMenuPanel ();
}
}
}
public void PauseMenu ()
{
if (pauseMenu = true) {
showPanelsMenu.ShowPausePanel ();
showPanelsMenu.HideMainMenuPanel ();
showPanelsMenu.HidePlayerUIPanel ();
}
else
{
if (pauseMenu = false) {
showPanelsMenu.HidePausePanel ();
}
}
}
public void PlayerUI ()
{
if (playerUI = true) {
showPanelsMenu.ShowPlayerUIPanel ();
showPanelsMenu.HidePausePanel ();
showPanelsMenu.HideMainMenuPanel ();
}
else
{
if (playerUI = false) {
showPanelsMenu.HidePlayerUIPanel ();
}
}
}
}
ShowPanelsMenu
using UnityEngine;
using System.Collections;
public class ShowPanelsMenu : MonoBehaviour {
public GameObject mainMenuPanel;
public GameObject pausePanel;
public GameObject playerUIPanel;
//Call this function to activate and display the main menu panel
public void ShowMainMenuPanel()
{
mainMenuPanel.SetActive (true);
}
//Call this function to deactivate and hide the main menu panel
public void HideMainMenuPanel()
{
mainMenuPanel.SetActive (false);
}
//Call this function to activate and display the Pause panel
public void ShowPausePanel()
{
pausePanel.SetActive (true);
}
//Call this function to deactivate and hide the Pause panel
public void HidePausePanel()
{
pausePanel.SetActive (false);
}
//Call this function to activate and display the Player UI
public void ShowPlayerUIPanel()
{
playerUIPanel.SetActive (true);
}
public void HidePlayerUIPanel()
{
playerUIPanel.SetActive (false);
}
}
I kind of understand what your saying @vittu1994. Like I said I am still quite new to Bools. Every tut I see does not really explain the methods of bool. It has been holding me back not fully understanding the bool when a lot of things use it. I appreciate any help explained.