Reset Input.GetJoystickNames() array

hi folks,

do you know if there is any way to reset the joystick array which is raised by one each time you plug in a new gamepad?

for example, if i connect 4 gamepads, the array looks like this:

[0] gamepad1 
[1] gamepad2
[2] gamepad3
[3] gamepad4

if i now disconnect the first 2 gamepads it looks like this:

[0] empty
[1] empty
[2] gamepad3
[3] gamepad4

i know, this behaviour is on purpose so that the player slots are not switched on a disconnect,
but what i want is that the gaps will be closed, gamepad3 becomes player1 and so on…

[0] gamepad3
[1] gamepad4

the only workaround i know is to close and reopen the editor or build.

do you know any better solution?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CharPlacer : MonoBehaviour
{

    public GameObject[] chars;
    public Transform[] startPosses;

    // Use this for initialization
    void Start()
    {
        int playerSetback = 0;
        for (int i = 0; i < Input.GetJoystickNames().Length; i++)
        {
            if (Input.GetJoystickNames() *== "")*

{
playerSetback++;
}
else //character creation
{
int realI = i - playerSetback;
GameObject curr = Instantiate(chars[0], startPosses[realI].position, Quaternion.identity);
curr.GetComponent().id = (realI + 1);
curr.GetComponent().prefix = “P” + (realI + 1).ToString() + “_”;
}
}
}

// Update is called once per frame
void Update()
{

}
}
What i do is “ignore” the empty spaces.
By counting a variable, i can fake that these empty spaces don’t exist!
@anszwa