File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,7 +13,6 @@ public class MenuOptionsInputController : MonoBehaviour
1313
1414 private int navigationDirection ;
1515 private Timer timer ;
16- private PlayerInput playerInput ;
1716
1817 public void SetActive ( bool active )
1918 {
@@ -23,19 +22,10 @@ public void SetActive(bool active)
2322 private void Awake ( )
2423 {
2524 timer = GetComponent < Timer > ( ) ;
26- playerInput = GetComponent < PlayerInput > ( ) ;
27-
28- SetControlScheme ( ) ;
25+
2926 RegisterToListeners ( true ) ;
3027 }
3128
32- private void SetControlScheme ( )
33- {
34- var controlSchemeName = InputMethods . GamepadIsAvailable ( ) ? InputMethods . GAMEPAD_CONTROL_SCHEME_NAME : InputMethods . KEYBOARD_AND_MOUSE_CONTROL_SCHEME_NAME ;
35-
36- InputMethods . SetControlSchemeToPlayerInputIfPossible ( playerInput , controlSchemeName ) ;
37- }
38-
3929 private void OnDestroy ( )
4030 {
4131 RegisterToListeners ( false ) ;
Original file line number Diff line number Diff line change 1- using System . Collections . Generic ;
21using UnityEngine . InputSystem ;
32
43public static class InputMethods
54{
6- public static readonly string KEYBOARD_AND_MOUSE_CONTROL_SCHEME_NAME = "Keyboard&Mouse" ;
7- public static readonly string GAMEPAD_CONTROL_SCHEME_NAME = "Gamepad" ;
8-
9- private static readonly Dictionary < string , InputDevice [ ] > inputDevicesByControlSchemeName = new ( )
10- {
11- { KEYBOARD_AND_MOUSE_CONTROL_SCHEME_NAME , new InputDevice [ ] { Keyboard . current , Mouse . current } } ,
12- { GAMEPAD_CONTROL_SCHEME_NAME , new InputDevice [ ] { Gamepad . current } }
13- } ;
14-
155 public static bool GamepadIsAvailable ( ) => Gamepad . current != null ;
16-
17- public static void SetControlSchemeToPlayerInputIfPossible ( PlayerInput playerInput , string controlSchemeName )
18- {
19- if ( playerInput != null && playerInput . user . valid )
20- {
21- playerInput . SwitchCurrentControlScheme ( controlSchemeName , GetInputDevicesByControlSchemeName ( controlSchemeName ) ) ;
22- }
23- }
24-
25- private static InputDevice [ ] GetInputDevicesByControlSchemeName ( string controlSchemeName ) => inputDevicesByControlSchemeName . TryGetValue ( controlSchemeName , out var inputDevices ) ? inputDevices : new InputDevice [ 0 ] ;
266}
You can’t perform that action at this time.
0 commit comments