(Linux Player) Why does Input.GetButtonDown return true every frame?

I’ve recently been testing my game on Linux and noticed that Input.GetButtonDown(“Submit”) button on the new UI seemed to be true every frame that the button was held.

To test further, I created a new project with one scene and the following script:

using UnityEngine;

public class TestInput : MonoBehaviour
{
	int mCount = 0;
	
	void Update()
	{
		if (Input.GetButtonDown("Submit"))
		{
			mCount++;
		}
	}
	
	void OnGUI()
	{
		GUILayout.Label("Count: " + mCount.ToString());
	}
}

I built for linux and tested on Lubuntu 14.10 and Ubuntu 14.04 (both fully updated) with the same result - GetButtonDown is functioning like GetButton.

This is using a controller/joystick to test. I have tried two - a generic HID and an Xbox 360 controller. Pressing Enter on the keyboard works as expected (only triggers once per press). I have tried the jstest utility in Linux and it reports down events only once as you would expect.

In the editor and build for Windows it functions normally (with the same controllers).

I am using Unity 4.6.0f3.

if this bugs are always appear, you need to report this problem to Unity.

i don’t know how to solve this problem since I don’t have Linux OS to solve it, but there is work-around to solve this problem, you need to add little more code.

 private bool m_btnInUse = false;
void Update()
{
   if( Input.GetButtonDown("Submit")) {
      if(m_btnInUse == false) {
           // Call your event function here.
           m_btnInUse = true;
      }
   }
   if(!Input.GetButtonDown("Submit")) 
       m_btnInUse = false;
}

This is indeed a bug and you can follow it at Unity Issue Tracker - Input.GetButtonDown returns true for as long as it is held