So I have this code I attached to a camera trying to make a pause menu of sorts but when I clicked the button timescale wouldn’t be set back 1 so I debugged and still can’t get it to work. I feel like its something simple staring at me in the face. Basically the problem is the button doesn’t pick up being clicked
function Update () {
//pause the game
if(Input.GetKeyDown(KeyCode.Escape) paused == false){
paused = true;
Time.timeScale = 0;
}
}
function OnGUI () {
//display menu if paused
if(paused){
if (GUI.Button(Rect(10,70,50,30),"Click"))
Debug.Log("Clicked the button with text");
}
}
It’s very weird, I’ve just tried your code and it works fine (as you expect it to work). I guess you are accessing “paused” somewhere else or something else is wrong but not the script that you showed.
Your right made a new scene worked fine. I guess I’ll just have this be a whole other script. I had this squeezed in with just my mouse look camera script. Still not sure what interfered since it’s not used anywhere else whatever its fine now. Edit: Just figured it out and feel so stupid I was using lock cursor to center so when I clicked the button the mouse went to the center before it activate the button. Well its sorted out now