Search Unity

strange behavior for GetKeyDown in AppleTV

Discussion in 'UGUI & TextMesh Pro' started by kaharoth, Jun 6, 2019.

  1. kaharoth

    kaharoth

    Joined:
    Feb 13, 2015
    Posts:
    21
    Hi,
    I have a strange behavior of Input.GetKeyDown when running on tvOS after I upgraded to Unity 2019.1.5f1, the latest release.
    Consider this code inside a GameObject script:

    Code (CSharp):
    1.  void Update() {
    2.    if (Input.GetKeyDown(KeyCode.JoystickButton15)) {
    3.       Debug.Log("did press play button");
    4.    }
    5. }
    Before upgrading Unity I had only 1 print of "did press play button" when keeping the play button pressed on Apple TV Remote.
    Now the "did press play button" print is called multiple times when keeping the play button pressed in the Apple TV Remote, until I release it. Is this a new expected behavior?

    Thank you for your support,

    Giovanni
     
    Last edited: Jun 6, 2019
    Fattie likes this.
  2. kaharoth

    kaharoth

    Joined:
    Feb 13, 2015
    Posts:
    21
    Hi there, since nobody has answered yet I just want to add some information for helping you to better understand the problem.

    The problem of multiple calls to the event triggered by the Apple TV Remote buttons, also appears when using a GameObject with a component Button (Script) with a OnClick() attached function. This function is called multiple times forever when keeping the button of the Apple TV Remote pressed.

    However, when I use Unity version LTS 2017.4.28f1 there is no problem and GetKeyDown and OnClick() work as expected, but as soon as I update to version LTS 2018.4.1f1 the problems appear. Note that during this upgrade I have to update the API from
    UnityEngine.Apple.TV.Remote
    to
    UnityEngine.tvOS.Remote
    .
     
  3. nickfourtimes

    nickfourtimes

    Joined:
    Oct 13, 2010
    Posts:
    219
    I'm going to jump in here and add that I think I'm experiencing the same problem. I have my thumbpad click defined in the Input manager as shown in the attached image. However, when I poll
    Input.GetButtonDown("tvOS click");
    in my Update() function, it returns true for every frame that the thumpad is clicked, rather than just the first frame where it is clicked.

    This is in Unity 2019.1.6f1.
     

    Attached Files:

  4. nickfourtimes

    nickfourtimes

    Joined:
    Oct 13, 2010
    Posts:
    219
    I've tested this with an empty project in U2019.2.0f1, and the bug is still present: clicking the tvOS remote thumbpad will return true with
    Input.GetButtonDown("tvOS click");
    for as long as the thumbpad is down, which is the expected behaviour of
    Input.GetButton()
    , not
    Input.GetButtonDown()
    .
     
  5. nickfourtimes

    nickfourtimes

    Joined:
    Oct 13, 2010
    Posts:
    219
    I reported this as a bug, and was informed that it's a duplicate of this existing issue, which seems to be resolved in future versions of Unity.
     
  6. nickfourtimes

    nickfourtimes

    Joined:
    Oct 13, 2010
    Posts:
    219
    Tested it in U2019.2.2f1, and the bug is gone: GetButtonDown() reports true only on the frame where the thumbpad is first clicked.
     
  7. Fattie

    Fattie

    Joined:
    Jul 5, 2012
    Posts:
    476
    BTW Giovanni,

    Thanks for this great sample code!

    if (Input.GetKeyDown(KeyCode.JoystickButton15)) {