Problem with controler detection

Im making a setup screen for my sports game. What i want it to do is to enable the controller icon if it detects the controller


3593053--291145--2018-08-05_20h58_54.png

    // Use this for initialization
    void Start()
    {
        if (Input.GetJoystickNames()[0] == "true")
        {
            playerOne.SetActive(true);

        }
        else
        {
            playerOne.SetActive(false);
        }

        if (Input.GetJoystickNames()[1] == "true")
        {
            playerTwo.SetActive(true);

        }
        else
        {
            playerTwo.SetActive(false);
        }
    }

The main problem is that when the player one controller is detected the icon disables and te player two icon is enabled

GetJoystickNames as per the documentation returns a string array of “meaningful names”:

This line:

if (Input.GetJoystickNames()[0] == "true")

And this line:

if (Input.GetJoystickNames()[1] == "true")

Unless you happen to attach a controller whose driver reports its name to be “true”, will never be equal to “true”.

Furthermore… these lines of code will throw exceptions if you have run this script and NOT have 2 gamepads attached.