Search Unity

Question Button stops working after a while

Discussion in 'UGUI & TextMesh Pro' started by spjennie, Mar 15, 2023.

  1. spjennie

    spjennie

    Joined:
    Oct 7, 2020
    Posts:
    5
    Hi guys, I am having an issue where my button stops working after a while during gameplay. It works most of the time, but sometimes after the game is on for a long time, it stops working.

    When the button stops working, I close the game and restart it, and it works perfectly fine after that.

    Would it be an issue with the game running a long time or the computer? The computer is a bit old.

    Thanks.
     
  2. QuinnWinters

    QuinnWinters

    Joined:
    Dec 31, 2013
    Posts:
    494
    When you say it "stops working" what do you mean exactly? Does the highlight still function on it or is it the onclick event that stops firing?

    Something has to be interfering with it. Buttons don't just stop working for no good reason, even on older machines. Often this situation is caused by some other invisible UI element getting in front of it.
     
  3. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,481
    Please use the UI forums for UI questions, not the 2D forum. I'll move your post to what I guess is a UGUI question. No idea if it;s UGUI or UIToolkit,
     
  4. spjennie

    spjennie

    Joined:
    Oct 7, 2020
    Posts:
    5
    The game is a 90 second long game and every time I start up the game, I have to press a start button. This is the button that doesn't work after a while. It doesn't fire the onclick event to move onto starting the game.

    How would I be able to catch the invisible UI element in front of it, if there is one? It is hard to replicate the error and happens rarely after the game is played over and over a couple hours in.

    If the game is the same and repeating every time, why would the button just stop working? And then work again after the game is closed and started up again.

    Thanks.
     
  5. D12294

    D12294

    Joined:
    Oct 6, 2020
    Posts:
    81
    Sounds like it's something with event management. Do you add and remove listeners in your code? Or maybe because of generated and not destroyed objects.