Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

How to disable GUI Menu when you click on a button in the GUI

$
0
0
Sorry if that was confusing... I have a GUI menu, and I have a journal tab. So when I click that I have a GUI Texture that enables and displays. But the GUI Menu is still in front of it. What I want to do is disable the Gui menu without making the Time.timeScale = 1. I have it to when it's paused it equals 0. If anyone can help, thank you so, so much!! using UnityEngine; using System.Collections; public class PauseMenu : MonoBehaviour { public GUISkin skin; public bool paused = false; public Texture blackTexture; public float alphaFadeValue = 0.4f; public GUITexture game; void Awake(){ game.enabled = false; } void Update(){ if (paused) { Time.timeScale = 0; Screen.showCursor = true; Screen.lockCursor = false; } else { Time.timeScale = 1; Screen.showCursor = false; Screen.lockCursor = true; } if (Input.GetKeyDown (KeyCode.Escape)) { paused = !paused; game.enabled = false; } } void OnGUI(){ if (paused) { Pause (); alphaFadeValue = 0.5f; GUI.color = new Color (alphaFadeValue, alphaFadeValue, alphaFadeValue, alphaFadeValue); GUI.DrawTexture (new Rect (0, 0, Screen.width, Screen.height), blackTexture); } else { alphaFadeValue = 0f; } } void Pause(){ GUILayout.BeginArea(new Rect ((Screen.width * 0.5f) - 50, (Screen.height * 0.5f) - 100, 100, 200)); if (GUILayout.Button ("Resume")) { paused = !paused; if (game.enabled == true) { game.enabled = false; } } if (GUILayout.Button ("Main Menu")) { Application.LoadLevel ("MainMenu"); } if (GUILayout.Button ("Journal Entries")) { game.enabled = true; } if (GUILayout.Button ("Quit")) { Application.Quit; } GUILayout.EndArea(); } }

Viewing all articles
Browse latest Browse all 171066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>