Pause menu GUI Script Disabled
Hi! I've made a simple pause menu for my game but I've noticed that when I pause the game my GUI Textures are not disabling. My GUI script is making that when I hit an object with "certainTag" It's activating a texture. When I pause the game over the object with the "ceratinTag" the texture is still active! My first idea was to access the GUI script from my Pause script but the problem is that i need to make tons of variables to be able to disable all of the Textures! So my second idea was to make a list where i can put all of the objects and through single variable to disable them! But the list cant access the "disabled" function! My questions is how can i make this to work?
Here is my Pause script;
public GameObject pauseUi;
public Transform Player;
//public GuiScript _disabled;
//public GuiScript[] disabledList = new GuiScript[1];
private bool paused = false;
void Start()
{
pauseUi.SetActive (false);
}
void Update()
{
if (Input.GetButtonDown ("Pause"))
{
paused = !paused;
}
if (paused)
{
pauseUi.SetActive(true);
Time.timeScale = 0;
Player.GetComponent<FirstPersonController>().enabled = false;
}
if (!paused)
{
pauseUi.SetActive(false);
Time.timeScale = 1;
Player.GetComponent<FirstPersonController>().enabled = true;
}
}
And here is my GUI script;
public Texture levelsGUI;
private bool guiEnabled = false;
void OnTriggerStay(Collider co)
{
if (co.tag == "Player")
{
guiEnabled = true;
}
}
void OnTriggerExit(Collider co)
{
if (co.tag == "Player")
{
guiEnabled = false;
}
}
void OnGUI()
{
if (guiEnabled == true)
{
GUI.DrawTexture(new Rect(Screen.width / 2.8f, Screen.height / 2f, 500, 500), levelsGUI);
}
}
Comment