Search Unity

Question Button OnClick() Runs Indefinitely

Discussion in 'UGUI & TextMesh Pro' started by jellyjamgames, Mar 3, 2021.

  1. jellyjamgames

    jellyjamgames

    Joined:
    Apr 4, 2020
    Posts:
    2
    I was working on a project where the button worked at one point and all of a sudden is acting funny. When clicking the button it will activate on the mouse down and then keep repeating itself as if it was being pressed over and over and over...until you click somewhere else that isn't the button. I was using the Unity UI Button On Click () event that was tied to a method that only ran once in the script and was clicking and releasing only once on the mouse.

    I updated to 2020.2.6.f1 and created a new project. Added a Canvas. Added a Button. Clicked Play and pressed the button. I can see the button color changing from selected to not selected and back over and over. Something is either wrong here or wrong with my settings?

    I'm not sure what to do here and I've tried to Google it but only find people with similar issues and the fixes don't quite work. I've spent most of my time looking at the Input Manager settings for Submit/Submit/Cancel. I've tried playing with the EventSystem as well. I'm not too familiar with these as I've never had to change the defaults. In my research, I removed all Positive Button and Alt Positive Button entries for both Submits and got it to work. However, it messes with clicking on other GameObjects in the scene so that those don't function correctly.
     
  2. jellyjamgames

    jellyjamgames

    Joined:
    Apr 4, 2020
    Posts:
    2
    I found that the Button's Navigation setting was set to Automatic for some reason. Setting it to None stopped the behavior. Not sure if this is the answer I should be using, but it's working for now.
     
    JKrypto likes this.