Search Unity

Input.JoystickNames() clears when any joystick is disconnected [IsBug ? new BugReport() : null]

Discussion in 'Scripting' started by Polymorphik, Sep 3, 2017.

  1. Polymorphik

    Polymorphik

    Joined:
    Jul 25, 2014
    Posts:
    599
    Hello,

    So in Unity 5.6.0f3 on Mac OS X when multiple joysticks are connected and a single one is disconnected, Input.JoystickNames() returns a length of 0 for 1 frame and then repopulates with the correct Joysticks that were never disconnected in the first place.

    Example
    Frame 1 Connected: Xbox One, Ds4 -> Input.JoystickNames().Length = 2
    Frame 2 Disconnected: Ds4
    Frame 3 Reported By Unity: Input.JoystickNames().Length = 0
    Frame 4 Connected: Xbox One -> Input.JoystickNames().Length = 1

    Is this happening to anyone else..?

    I have a loop running a Coroutine with yield return EndOfFrame <- Cached

    Based off the Execution Order noted by Unity this should not matter but I am just trying to rule out a flaw in my logic vs Unity bug. Also this same logic I have used in 4.X and had no problem.