Search Unity

Bug UI continually registers the same button click

Discussion in 'Input System' started by ranjansikand, May 18, 2022.

  1. ranjansikand

    ranjansikand

    Joined:
    Apr 8, 2021
    Posts:
    110
    For background, I'm using the Input System (already switched in Event System, don't worry) and I've created a small UI system. For whatever reason, I noticed that, after I closed the window once, it would keep closing immediately once I reopened it. To isolate the issue, I split functions and added Debug statements.

    This could be my fault, but I've never had this issue occur before.

    upload_2022-5-18_15-12-34.png
    This is the button in question, which calls this function:
    Code (CSharp):
    1. public void OnDiscardButton() {
    2.         Debug.Log("Close pickup menu (GUI Button)");
    3.         _gui.SetActive(false);
    4.     }
    As mentioned, if I reopen the window later, it will close again immediately.

    However, if I click somewhere else in the game window, it reopens with no issue, which is why I figured this was an issue with the Input System, in that it continually registers a click in the same place. The same issue is happening with all the other buttons on the panel.
     

    Attached Files:

  2. ranjansikand

    ranjansikand

    Joined:
    Apr 8, 2021
    Posts:
    110
    New project, completely different system, but I'm still getting the same issue. I have to click somewhere else otherwise I'll register the same mouse-click on a new screen.

    Edit: Had a hard time finding it, but the issue was that it was missing an OnScreenButton component
     
    Last edited: Feb 3, 2023