Some of my buttons need two clicks to run the OnClick()

I have an interesting problem where some, not all, of my buttons need to be pressed twice before they register as an actual click.

When I click the first time the button transition works properly, meaning the button highlight and pressed colors change correctly, however I have to click a second time for the button OnClick() to work properly. The button works as expected after this point.

There is no UI or other raycast target that is blocking the button.

I have never dealt with anything like this before. Has anyone else dealt with this issue and have a solution? Thank you.

I had some problems like that. After many tests, I realized that the game objects that were wrong were the game objects that were disabled. So I left all enabled and created a script to disable the game objects after 0.1s the scene started. After that all the buttons worked correctly.

The Awake () method also solves many problems, in many cases it is better to use Awake ().

I’m having the same problem and it’s driving me crazy. Can’t seem to find an exact repro either but it’s definitely not the desired result.

I have the same problem. When I turn off the phone it works on the first click. They when I restart the game it takes 2 click. The script is on a game manager. any solutions?

Create an empty game object and attach this script

private void Update()
{
if (gameObject.activeInHierarchy)
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
Destroy(gameObject);
}
}

then in on click set GameObject to active and it will reset the scene along the Reset GameObject will also reset. Hope that helps save you the time it took me :),

Just had this issue and found the solution was to remove all but the necessary functionality to start my game from Awake. I moved some code to Start() and out of awake and things worked.

Hope this helps.