- Home /
UI button touch input problem when UI is SetActive during game play
Hey everyone I was hoping to figure this out on my own but I've spent a lot of time trying to fix the issue to no prevail. I have a Game Over UI that gets set active when the player dies. The touch input for all my UI buttons in the game are functioning as they should and if I start the scene with the Game Over UI set as active the touch input works fine. But if I run the game normally with the Game Over UI set inactive by default, when the player dies and the UI come up the touch inputs no longer work with the buttons. The mouse click still functions in the editor though. Any idea what could be going wrong here?
In addition, If I run the game at lets say the last level with the UI set active, then click the main menu button on the UI (Which functions correctly because the game started with the UI active) and start a new game and die on a level where the UI is set correctly, when the UI sets active in that level the input functions correctly.
Answer by Map-Builder · May 28, 2020 at 11:47 PM
activate it only when he dies.
not enough info. are you using a button ? what do you call a gameover UI ? either something is not activated or something is over something else, or your game is paused with a fixedupdate not being called because it's 50 times per second @1 and never called @0 beacause physics are frozen (or not, but I think that's it, just check)
The game over UI is a canvas that gets set active when the players lives = 0. It does not pause the game, It has the UI buttons attached to the canvas, and the buttons all function when the UI is activated on player death using a mouse click but not with touch input. If I run the game in the editor with the game over UI set active at the start of the scene then the touch input works correctly.
Either there's something that is being up the UI or the function which is supposed to be triggered by the button does not work. I'm a bit surprised that the function you are supposed to call in game does do the job in editor.
I found a hacky fix for the time being, I noticed that the touch input worked correctly on the first 3 tutorial levels of the game and found the only difference between those levels and the main levels was an added Canvas with Game instructions. So I placed the tutorial canvas into the main levels and hit play and when the Game Over UI activated on the players death the buttons functioned correctly.
Your answer
Follow this Question
Related Questions
Onscreen fire button for FPS games. 1 Answer
Taking Input from Android phones 1 Answer
Force touch to only work on a new touch - buttons 0 Answers
Help with a button 1 Answer