void InitInputConfigurations() { int playerNumber = InputMng.GetJoystickNames().Length; if (playerNumber > 4) { playerNumber = 4; } string confNamePrefix = "Win"; if (Application.platform == RuntimePlatform.OSXPlayer || Application.platform == RuntimePlatform.OSXEditor) { confNamePrefix = "OS_X"; } for (int i = 0; i < playerNumber; i++) { TeamUtility.IO.PlayerID playerId = (TeamUtility.IO.PlayerID)System.Enum.GetValues(typeof(TeamUtility.IO.PlayerID)).GetValue(i); InputMng.SetInputConfiguration(confNamePrefix + "_gamepad_" + (i + 1), playerId); } if (playerNumber < 4) { TeamUtility.IO.PlayerID playerId = (TeamUtility.IO.PlayerID)System.Enum.GetValues(typeof(TeamUtility.IO.PlayerID)).GetValue(playerNumber); InputMng.SetInputConfiguration("keyboard", playerId); playersConnected = playerNumber + 1; } else { playersConnected = 4; } }
private IEnumerator UpdateJoystickCount() { while (true) { _joystickCount = InputManager.GetJoystickNames().Length; if (_inputDevice == InputDevice.Joystick && _joystickCount == 0) { Debug.LogWarning("Lost connection with joystick. Switching to keyboard and mouse input."); SetInputDevice(InputDevice.KeyboardAndMouse); } yield return(new WaitForSeconds(updateJoystickCountInterval)); } }
public void OnInitializeAfterScriptReload() { if (_instance != null && _instance != this) { Debug.LogWarning("You have multiple InputAdapter instances in the scene!", gameObject); } else if (_instance == null) { SetInputManagerConfigurations(); SetInputDevice(InputDevice.KeyboardAndMouse); _instance = this; _joystickCount = InputManager.GetJoystickNames().Length; _lastInputDeviceCheck = Time.deltaTime; } }
private void Awake() { if (_instance != null) { Destroy(this); } else { SetInputManagerConfigurations(); SetInputDevice(InputDevice.KeyboardAndMouse); _instance = this; _joystickCount = InputManager.GetJoystickNames().Length; if (dontDestroyOnLoad) { DontDestroyOnLoad(gameObject); } } }
public static string[] GetJoystickNames() { return(InputManager.GetJoystickNames()); }