public override void Update() { if (interval.GetElapsedTime().seconds < UPDATE_INTERVAL) { return; } interval.Reset(); if (strCache.Length > 100) { strCache = string.Empty; } foreach (var gamepad in UnityEngine.InputSystem.Gamepad.all) { ConnectGamepad(GetUniqueGamepadId(gamepad)); } foreach (var gamepad in gamepads) { if (!UnityEngine.InputSystem.Gamepad.all.Any(g => GetUniqueGamepadId(g) == gamepad.Id)) { DisconnectGamepad(gamepad.Id); } } }
public override void Update() { // Update Mouse Position { var position = UnityEngine.Input.mousePosition; mousePosition = new Vector2Int((int)position.x, (int)position.y); } if (interval.GetElapsedTime().seconds < UPDATE_INTERVAL) { return; } interval.Reset(); var joystickNames = UnityEngine.Input.GetJoystickNames(); foreach (var gamepadId in joystickNames) { ConnectGamepad(gamepadId); } foreach (var gamepad in gamepads) { if (!joystickNames.Contains(gamepad.Id)) { DisconnectGamepad(gamepad.Id); } } }