- Home /
Use UI buttons with Time.timeScale=0?
I'm creating a pause menu (which sets Time.timeScale to 0) and none of my buttons work. I've already tried using an animator with unscaled time (in the canvas and then in the buttons individually). What am i doing wrong? There is a event system in the scene and every button has it respective On Click function set (With a Debug.Log just in case). How can I use UI buttons with Time.timeScale = 0? Or, is it a better way to pause my game?
I think we need to see code at this point. Changing timescale to zero doesn't affect the usage of buttons, thus maybe you are disabling the canvas or some other code-fu you are doing?
You can test this by creating a new scene. Adding a UI button. Creating a small script with an onClick() method for changing the timescale from 0 to 1 (add some debug logs), then apply it to the button. You will see it change the time scale back an forth.
Answer by MahaSaka · Nov 26, 2018 at 03:44 PM
I found my answer here: https://answers.unity.com/questions/1148727/ui-button-not-working-2.html . It turns out that my panel was higher in the hierarchy than my buttons, making it draw above them. That's why the buttons were blocked.
Answer by game4444 · Nov 26, 2018 at 09:23 AM
It works perfectly fine. In Time.timeScale = 0; because you cant resume your game in case if it didn't work. Please check your canvas or panel which you are enabling on pause Button and check whether your buttons are on top of panel.
I still don't know what to do. I checked the canvas and nothing seems off. I't has a graphic raycaster and every button is inside of it.
Your answer
Follow this Question
Related Questions
Hidden Canvas, doesn't disable interaction with buttons. 1 Answer
Augmented reality - UI - How do I augment an User Interface Canvas properly? 0 Answers
I made an resume button, but I don't know how to code it to close my pause menu, any tips? 2 Answers
Show UI Button press color from script when invoking onClick 2 Answers
Unity5 UI - How to trigger button click event while preventing menu item deselect event? 1 Answer