- Home /
UI Enabled not working?
So, I am trying to make a pause menu by overlaying an image over the game (which would have a half transparent black background so you know its paused), and the image is the parent of all the buttons and stuff. The menu button I am using is linked to the PauseManager that I created, which has the script below attached to it. The only problem is that the .enabled
scripts aren't working. I am getting no errors, and the Debug.Log("Switch!");
message is appearing in the console. Also, when you click the button, the game freezes up the engine for a second. Does anyone know how or what this is? Thanks!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Pause : MonoBehaviour {
public Image menu;
public Button menuBtn;
public bool isMenu;
public void menuSwitch() {
Debug.Log("SWITCH!");
menu.enabled = true;
menuBtn.enabled = false;
}
}
Take into account that when pausing any function that uses update won't work as Time.timescale is zero
Well, I'm not actually pausing anything, it's just an overlay being enabled and disabled to act like a pause menu. I still don't understand why it would show the debug message and not run the enabled code, without returning any errors.
Answer by Pnvanol · Jun 24, 2018 at 12:54 PM
Are you filling the image and button in the editor? Take into account that enabled don't activate the game object instead it enables the script
Your answer
Follow this Question
Related Questions
I made an resume button, but I don't know how to code it to close my pause menu, any tips? 2 Answers
how do i make my button's source image bigger without changing the button hover/clickable area? 0 Answers
Scrollable Achievement Tabs? 1 Answer
Change the button target image alpha 1 Answer
UI Image not blocking raycast 3 Answers