void ControllerSetup() { string[] joystickNames = Input.GetJoystickNames(); int controllerCount = 0; for (int counter = 0; counter < joystickNames.Length; counter++) { if (joystickNames[counter] == "Controller (Xbox 360 Wireless Receiver for Windows)" || joystickNames[counter] == "Controller (Rumble Gamepad F510)" || joystickNames[counter] == "Controller(XBOX 360 For Windows)") { Debug.Log("Found " + joystickNames[counter] + "In position " + (counter + 1)); string[] contr = new string[5]; contr[0] = "J" + (counter + 1) + " Left Stick X"; contr[1] = "J" + (counter + 1) + " Left Stick Y"; contr[2] = "J" + (counter + 1) + " XB Right Stick X"; contr[3] = "J" + (counter + 1) + " XB Right Stick Y"; contr[4] = "J" + (counter + 1) + " XB Triggers"; GameObject selection = GameObject.Instantiate(selectionTemplate); selection.GetComponent <Controller>().array = contr; selection.GetComponent <Image>().sprite = genericControllerIcons[controllerCount]; p1.AddState(selection); selection = GameObject.Instantiate(selectionTemplate); selection.GetComponent <Controller>().array = contr; selection.GetComponent <Image>().sprite = genericControllerIcons[controllerCount]; p2.AddState(selection); controllerCount++; } else if (joystickNames[counter] == "Ultimate Arcade Controller v2.0") { Debug.Log("Found " + joystickNames[counter]); string[] contr = new string[5]; contr[0] = "J" + (counter + 1) + " FF Face X"; contr[1] = "J" + (counter + 1) + " FF Face Y"; contr[2] = "J" + (counter + 1) + " FF Right Stick X"; contr[3] = "J" + (counter + 1) + " FF Right Stick Y"; contr[4] = "J" + (counter + 1) + " FF Right Triggers"; GameObject selection = GameObject.Instantiate(selectionTemplate); selection.GetComponent <Controller>().array = contr; selection.GetComponent <Image>().sprite = ultimateArcadeIcons[1]; p1.AddState(selection); selection = GameObject.Instantiate(selectionTemplate); selection.GetComponent <Controller>().array = contr; selection.GetComponent <Image>().sprite = ultimateArcadeIcons[1]; p2.AddState(selection); ////////////////////////////////////////////////////////////////////////////////// contr[0] = "J" + (counter + 1) + " FF DPad X"; contr[1] = "J" + (counter + 1) + " FF DPad Y"; contr[2] = "J" + (counter + 1) + " Left Stick X"; contr[3] = "J" + (counter + 1) + " Left Stick Y"; contr[4] = "J" + (counter + 1) + " FF Left Triggers"; selection = GameObject.Instantiate(selectionTemplate); selection.GetComponent <Controller>().array = contr; selection.GetComponent <Image>().sprite = ultimateArcadeIcons[2]; p1.AddState(selection); selection = GameObject.Instantiate(selectionTemplate); selection.GetComponent <Controller>().array = contr; selection.GetComponent <Image>().sprite = ultimateArcadeIcons[2]; p2.AddState(selection); ////////////////////////////////////////////////////////////////////////////////// contr[0] = "J" + (counter + 1) + " Left Stick X"; contr[1] = "J" + (counter + 1) + " Left Stick Y"; contr[2] = "J" + (counter + 1) + " FF Right Stick X"; contr[3] = "J" + (counter + 1) + " FF Right Stick Y"; contr[4] = "J" + (counter + 1) + " FF Triggers"; selection = GameObject.Instantiate(selectionTemplate); selection.GetComponent <Controller>().array = contr; selection.GetComponent <Image>().sprite = ultimateArcadeIcons[0]; p1.AddState(selection); selection = GameObject.Instantiate(selectionTemplate); selection.GetComponent <Controller>().array = contr; selection.GetComponent <Image>().sprite = ultimateArcadeIcons[0]; p2.AddState(selection); ////////////////////////////////////////////////////////////////////////////////// } } p1.SetState(0); controllers [0].array = p1.stateObject.GetComponent <Controller> ().array; p2.SetState(1); controllers [1].array = p2.stateObject.GetComponent <Controller> ().array; }