Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Resolved [New Inputsystem 1.0.2] Input uses "path" instead of "effectivePath"/"overridePath"

Discussion in 'Input System' started by Thuztor, Apr 13, 2021.

  1. Thuztor

    Thuztor

    Joined:
    Sep 16, 2017
    Posts:
    5
    I can't find a solution how to construct the code, so that the effectivePath/overridePath is used by my code.
    I'm using:
    - [Behavior: Invoke C# Unity Events] in the Player Input Component as an own gameobject (I've tested the component on the Player gameobject, too).
    - A script "Player_Input.cs": This script controls every action/binding and sends values to other scripts.
    - A script "Hotkey_Change.cs": This script should show bindings on buttons and with "onClick" the player can change the binding of the specific action -> works well so far (correct binding on buttons, even after rebinding), but the actual rebinding don't takes occur.
    The 3 Debug.Logs at the end are showing the right path of the action.
    - A script "Buttons_InGameMenu.cs": This script controls the visibility of the inGame menus and also it enables and disables the PlayerActionMap for rebinding.

    So, probably I'm a bit blind and someone has the answer.
    Following the scripts:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.InputSystem;
    5.  
    6. public class Player_Input : MonoBehaviour
    7. {
    8.  
    9.     [HideInInspector] public LewdWitch _controls = null;
    10.  
    11.     // Script Access
    12.     private Player_Attack _plAtt_script;
    13.     private Player_TakeObj _plTObj_script;
    14.     private Player_ThrowObj _plThObj_script;
    15.     private Levitation _levi_script;
    16.     private Player_Weapon _plWea_script;
    17.     private TeleAttack _plTeleAtt_script;
    18.     private player_movement _plMove_script;
    19.     private Aiming _aim_script;
    20.     private ShowInfoUI _showInfoUI_script;
    21.     private Zoom _zoom_script;
    22.     private Player_Stats _pStats_script;
    23.     private MJump _mjump_script;
    24.     private Player_Controls plyCon_script;
    25.     private MenuOpen menuOpen_script;
    26.  
    27.     private void Start()
    28.     {
    29.  
    30.  
    31.         _controls.Enable();
    32.  
    33.         _plAtt_script = GetComponent<Player_Attack>();
    34.         if (_plAtt_script == null)
    35.         {
    36.             Debug.LogError("Script: Player_Attack.cs missing! Please add it to the PLAYER.");
    37.             return;
    38.         }
    39.  
    40.         _plTObj_script = GetComponent<Player_TakeObj>();
    41.         if (_plTObj_script == null)
    42.         {
    43.             Debug.LogError("Script: Player_TakeObj.cs missing! Please add it to the PLAYER.");
    44.             return;
    45.         }
    46.  
    47.         _plThObj_script = GetComponent<Player_ThrowObj>();
    48.         if (_plThObj_script == null)
    49.         {
    50.             Debug.LogError("Script: Player_ThrowObj.cs missing! Please add it to the PLAYER.");
    51.             return;
    52.         }
    53.  
    54.         _levi_script = GetComponent<Levitation>();
    55.         if (_levi_script == null)
    56.         {
    57.             Debug.LogError("Script: Levitation.cs missing! Please add it to the PLAYER.");
    58.             return;
    59.         }
    60.  
    61.         _plWea_script = GetComponent<Player_Weapon>();
    62.         if (_plWea_script == null)
    63.         {
    64.             Debug.LogError("Script: Player_Weapon.cs missing! Please add it to the object PLAYER.");
    65.             return;
    66.         }
    67.  
    68.         _plTeleAtt_script = GetComponent<TeleAttack>();
    69.         if (_plTeleAtt_script == null)
    70.         {
    71.             Debug.LogError("Script: TeleAttack.cs missing! Please add it to the object PLAYER.");
    72.             return;
    73.         }
    74.  
    75.         _plMove_script = GetComponent<player_movement>();
    76.         if (_plMove_script == null)
    77.         {
    78.             Debug.LogError("Script: player_movement.cs missing! Please add it to the object PLAYER.");
    79.             return;
    80.         }
    81.  
    82.         _aim_script = FindObjectOfType<Aiming>();
    83.         if (_aim_script == null)
    84.         {
    85.             Debug.LogError("Script: Aiming.cs missing! Please add it to the object UI/Pointer/SCRIPTS.");
    86.             return;
    87.         }
    88.  
    89.         _showInfoUI_script = FindObjectOfType<ShowInfoUI>();
    90.         if (_showInfoUI_script == null)
    91.         {
    92.             Debug.LogError("Script: Aiming.cs missing! Please add it to the object UI/Pointer/SCRIPTS.");
    93.             return;
    94.         }
    95.  
    96.         _zoom_script = GetComponent<Zoom>();
    97.         if (_zoom_script == null)
    98.         {
    99.             Debug.LogError("Script: player_movement.cs missing! Please add it to the object PLAYER.");
    100.             return;
    101.         }
    102.  
    103.         _pStats_script = GetComponent<Player_Stats>();
    104.         if (_pStats_script == null)
    105.         {
    106.             Debug.LogError("Script: Player_Stats.cs missing! Please add it to the object PLAYER.");
    107.             return;
    108.         }
    109.  
    110.         _mjump_script = GetComponent<MJump>();
    111.         if (_mjump_script == null)
    112.         {
    113.             Debug.LogError("Script: MJump.cs missing! Please add it to the object PLAYER.");
    114.             return;
    115.         }
    116.  
    117.         plyCon_script = GetComponent<Player_Controls>();
    118.         if (plyCon_script == null)
    119.         {
    120.             Debug.LogError("Script: Player_Controls.cs missing! Please add it to the object PLAYER.");
    121.             return;
    122.         }
    123.  
    124.         menuOpen_script = FindObjectOfType<MenuOpen>();
    125.         if (menuOpen_script == null)
    126.         {
    127.             Debug.LogError("Script: MenuOpen.cs missing! Please add it to the object PLAYER.");
    128.             return;
    129.         }
    130.  
    131.     }
    132.  
    133.     public void OnEnable()
    134.     {
    135.  
    136.         if (_controls == null)
    137.         {
    138.             _controls = new LewdWitch();
    139.         }
    140.  
    141.         //_controls.Enable();
    142.  
    143.         _controls.Player.Move.performed +=  HandleMove;
    144.         //_controls.Player.Move.Enable();
    145.  
    146.         _controls.Player.Run.performed += HandleRun;
    147.         //_controls.Player.Run.Enable();
    148.  
    149.         _controls.Player.Strike_Right.performed += HandleStrikeRight;
    150.         //_controls.Player.Strike_Right.Enable();
    151.         _controls.Player.Strike_Left.performed += HandleStrikeLeft;
    152.         //_controls.Player.Strike_Left.Enable();
    153.  
    154.         _controls.Player.Fire.performed += HandleAttack;
    155.         //_controls.Player.Fire.Enable();
    156.  
    157.         _controls.Player.ChangeHand.performed += HandleChangeHand;
    158.         //_controls.Player.ChangeHand.Enable();
    159.  
    160.         _controls.Player.Take.performed += HandleTake;
    161.         //_controls.Player.Take.Enable();
    162.  
    163.         _controls.Player.Telekinesis.started += HandleTelekinesis;
    164.         _controls.Player.Telekinesis.performed += HandleTeleAT;
    165.         _controls.Player.Telekinesis.canceled += CancleTeleAT;
    166.         //_controls.Player.Telekinesis.Enable();
    167.         _controls.Player.UpDown.performed += HandleUpDown;
    168.         //_controls.Player.UpDown.Enable();
    169.  
    170.         _controls.Player.AIM.performed += HandleAIM;
    171.         //_controls.Player.AIM.Enable();
    172.  
    173.         _controls.Player.Jump.performed += HandleJump;
    174.         //_controls.Player.Jump.Enable();
    175.  
    176.         _controls.Player.Info.performed += HandleInfo;
    177.         //_controls.Player.Info.Enable();
    178.  
    179.         _controls.Player.Zoom.performed += HandleZoom;
    180.         //_controls.Player.Zoom.Enable();
    181.  
    182.         _controls.Player.Menu.performed += HandleMenu;
    183.         //_controls.Player.Menu.Enable();
    184.     }
    185.  
    186.     void OnDisable()
    187.     {
    188.         _controls.Disable();
    189.  
    190.         //_controls.Player.Move.Disable();
    191.         //_controls.Player.Run.Disable();
    192.         //_controls.Player.Strike_Right.Disable();
    193.         //_controls.Player.Strike_Left.Disable();
    194.         //_controls.Player.Fire.Disable();
    195.         //_controls.Player.ChangeHand.Disable();
    196.         //_controls.Player.Take.Disable();
    197.         //_controls.Player.Telekinesis.Disable();
    198.         //_controls.Player.UpDown.Disable();
    199.         //_controls.Player.AIM.Disable();
    200.         //_controls.Player.Jump.Disable();
    201.         //_controls.Player.Info.Disable();
    202.         //_controls.Player.Zoom.Disable();
    203.         //_controls.Player.Menu.Disable();
    204.     }
    205.  
    206.     // MOVING
    207.     void HandleMove(InputAction.CallbackContext context)
    208.     {
    209.      
    210.         _plMove_script._moveAxis = context.ReadValue<Vector2>();
    211.  
    212.     }
    213.  
    214.     private void HandleRun(InputAction.CallbackContext context)
    215.     {
    216.  
    217.         if (plyCon_script._run == context.ReadValueAsButton())
    218.         {
    219.             plyCon_script._run = false;
    220.         }
    221.         else
    222.         {
    223.             plyCon_script._run = context.ReadValueAsButton();
    224.         }
    225.  
    226.  
    227.     }
    228.  
    229.     // Attack with weapons
    230.     private void HandleStrikeRight(InputAction.CallbackContext context)
    231.     {
    232.  
    233.         // Weapon in the players RIGHT hand
    234.         if (_plWea_script.wearWeapon_R == false && _plTObj_script.activeTake == true)
    235.         {
    236.             _plTObj_script._wantWeapon_R = context.ReadValueAsButton();
    237.         }
    238.  
    239.         if (_plWea_script.wearWeapon_R == true)
    240.         {
    241.  
    242.             if (_aim_script.AIM == false)
    243.             {
    244.  
    245.                 if (_plTObj_script.Weapon_R.GetComponent<ObjectSettings>().weaponType == ObjectSettings.WeaponType.STAB)
    246.                 {
    247.  
    248.                     _plWea_script._stabRight = context.ReadValueAsButton();
    249.  
    250.                 }
    251.                else if (_plTObj_script.Weapon_R.GetComponent<ObjectSettings>().weaponType == ObjectSettings.WeaponType.STRIKE)
    252.                 {
    253.  
    254.                     _plWea_script._strikeRight = context.ReadValueAsButton();
    255.  
    256.                 }
    257.                else if (_plTObj_script.Weapon_R.GetComponent<ObjectSettings>().weaponType == ObjectSettings.WeaponType.BLUNT)
    258.                 {
    259.  
    260.                     _plWea_script._bluntRight = context.ReadValueAsButton();
    261.  
    262.                 }
    263.  
    264.             }
    265.             else
    266.             {
    267.  
    268.                 _plThObj_script.throw_R = true;
    269.  
    270.             }
    271.  
    272.         }
    273.  
    274.     }
    275.  
    276.     private void HandleStrikeLeft(InputAction.CallbackContext context)
    277.     {
    278.  
    279.         // Weapon in the players LEFT hand
    280.         if (_plWea_script.wearWeapon_L == false && _plTObj_script.activeTake == true)
    281.         {
    282.             _plTObj_script._wantWeapon_L = context.ReadValueAsButton();
    283.         }
    284.  
    285.         if (_plWea_script.wearWeapon_L == true)
    286.         {
    287.  
    288.             if (_aim_script.AIM == false)
    289.             {
    290.  
    291.                 if (_plTObj_script.Weapon_L.GetComponent<ObjectSettings>().weaponType == ObjectSettings.WeaponType.STAB)
    292.                 {
    293.  
    294.                     _plWea_script._stabLeft = context.ReadValueAsButton();
    295.  
    296.                 }
    297.                else if (_plTObj_script.Weapon_L.GetComponent<ObjectSettings>().weaponType == ObjectSettings.WeaponType.STRIKE)
    298.                 {
    299.  
    300.                     _plWea_script._strikeLeft = context.ReadValueAsButton();
    301.  
    302.                 }
    303.                else if (_plTObj_script.Weapon_L.GetComponent<ObjectSettings>().weaponType == ObjectSettings.WeaponType.BLUNT)
    304.                 {
    305.  
    306.                     _plWea_script._bluntLeft = context.ReadValueAsButton();
    307.  
    308.                 }
    309.  
    310.             }
    311.             else
    312.             {
    313.  
    314.                 _plThObj_script.throw_L = true;
    315.  
    316.             }
    317.  
    318.         }
    319.  
    320.     }
    321.  
    322.     // Attack with magic
    323.     private void HandleAttack(InputAction.CallbackContext context)
    324.     {
    325.      
    326.         _plAtt_script._attack = context.ReadValueAsButton();  
    327.  
    328.     }
    329.  
    330.     private void HandleChangeHand(InputAction.CallbackContext context)
    331.     {
    332.  
    333.         if (_plAtt_script.leftHand == false)
    334.         {
    335.          
    336.             _plAtt_script.leftHand = context.ReadValueAsButton();
    337.  
    338.         }
    339.         else
    340.         {
    341.  
    342.             _plAtt_script.leftHand = false;
    343.  
    344.         }
    345.  
    346.     }
    347.  
    348.     private void HandleTake(InputAction.CallbackContext context)
    349.     {
    350.  
    351.         _plTObj_script.activeTake = context.ReadValueAsButton();
    352.  
    353.  
    354.     }
    355.  
    356.     private void HandleTelekinesis(InputAction.CallbackContext context)
    357.     {
    358.         if (_levi_script._telek == false)
    359.         {
    360.  
    361.            if ((_plWea_script.wearWeapon_R == false && _plAtt_script.leftHand == true) || (_plWea_script.wearWeapon_L == false && _plAtt_script.leftHand == false))
    362.             {
    363.  
    364.                 _levi_script._telek = context.ReadValueAsButton();
    365.  
    366.             }
    367.  
    368.         }
    369.         else if (_levi_script._telek == true)
    370.         {
    371.  
    372.             _levi_script._telek = false;
    373.             _levi_script.noHit = true;
    374.  
    375.         }
    376.  
    377.     }
    378.  
    379.     private void HandleUpDown(InputAction.CallbackContext context)
    380.     {
    381.         if (_levi_script.onCursor == true)
    382.         {
    383.             _levi_script.inputSOChange = context.ReadValue<Vector2>();
    384.             _levi_script.inputYSOChange = _levi_script.inputSOChange.y / 120;
    385.  
    386.             if (_levi_script.inputYSOChange > 1)
    387.             {
    388.                 _levi_script.inputYSOChange = 1;
    389.             }
    390.  
    391.             if (_levi_script.inputYSOChange < -1)
    392.             {
    393.                 _levi_script.inputYSOChange = -1;
    394.             }
    395.  
    396.             if (_levi_script.counterForSOCh > 0.0F)
    397.             {
    398.                 _levi_script.counterForSOCh -= Time.deltaTime;
    399.             }
    400.  
    401.             if (_levi_script.counterForSOCh <= 0.0F)
    402.             {
    403.  
    404.                 if (_levi_script.inputYSOChange == 1)
    405.                 {
    406.                     _levi_script._mObjAlig_script.changeSortingOrderBy = 1;
    407.                 }
    408.                 else if (_levi_script.inputYSOChange == -1 && _levi_script._mObjAlig_script.onObject == false)
    409.                 {
    410.                     _levi_script._mObjAlig_script.minusNextSO = true;
    411.                     _levi_script._mObjAlig_script.changeSortingOrderBy = 1;
    412.                 }
    413.  
    414.                 if (_levi_script.inputYSOChange == -1 && _levi_script._mObjAlig_script.onObject == true)
    415.                 {
    416.                     Debug.Log("Object can't sink, because it's on an object.");
    417.                 }
    418.  
    419.                 _levi_script.counterForSOCh = _levi_script.timeForSOCh;
    420.  
    421.             }
    422.  
    423.  
    424.         }
    425.     }
    426.  
    427.     private void HandleTeleAT(InputAction.CallbackContext context)
    428.     {
    429.         if (_plTeleAtt_script._teleAT == false)
    430.         {
    431.  
    432.            if ((_plWea_script.wearWeapon_R == false && _plAtt_script.leftHand == true) || (_plWea_script.wearWeapon_L == false && _plAtt_script.leftHand == false))
    433.             {
    434.  
    435.                 _plTeleAtt_script._teleAT = context.ReadValueAsButton();
    436.  
    437.             }
    438.  
    439.         }
    440.  
    441.     }
    442.  
    443.     private void CancleTeleAT(InputAction.CallbackContext context)
    444.     {
    445.         if (_plTeleAtt_script._shot == false && _plTeleAtt_script._inTeleAT == true)
    446.         {
    447.             _plTeleAtt_script._shot = true;
    448.         }
    449.         _plTeleAtt_script._hits = 0;
    450.         _plTeleAtt_script._teleAT = false;
    451.         _plTeleAtt_script._inTeleAT = false;
    452.  
    453.     }
    454.  
    455.     private void HandleAIM(InputAction.CallbackContext context)
    456.     {
    457.  
    458.         if (_aim_script.AIM == context.ReadValueAsButton())
    459.         {
    460.             _aim_script.AIM = false;
    461.         }
    462.         else
    463.         {
    464.             _aim_script.AIM = context.ReadValueAsButton();
    465.         }
    466.  
    467.     }
    468.  
    469.     private void HandleJump(InputAction.CallbackContext context)
    470.     {
    471.  
    472.         if (_pStats_script.PlrSE >= _mjump_script.SECost)
    473.         {
    474.             if (_plMove_script._NoMOVE == false && _aim_script.AIM == false)
    475.                 _mjump_script.jumpNow = context.ReadValueAsButton();
    476.  
    477.             if (_aim_script.AIM == true)
    478.                 _mjump_script.jumpNowAIM = context.ReadValueAsButton();
    479.         }
    480.  
    481.  
    482.     }
    483.  
    484.     private void HandleInfo(InputAction.CallbackContext context)
    485.     {
    486.  
    487.         if (_showInfoUI_script.Info == context.ReadValueAsButton())
    488.         {
    489.             _showInfoUI_script.Info = false;
    490.         }
    491.         else
    492.         {
    493.             _showInfoUI_script.Info = context.ReadValueAsButton();
    494.         }
    495.  
    496.     }
    497.  
    498.     private void HandleZoom(InputAction.CallbackContext context)
    499.     {
    500.  
    501.         _zoom_script._inputZoom = context.ReadValue<float>();
    502.  
    503.     }
    504.  
    505.     private void HandleMenu(InputAction.CallbackContext context)
    506.     {
    507.  
    508.         menuOpen_script._active = context.ReadValueAsButton();
    509.  
    510.     }
    511.  
    512. }

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.UI;
    5. using UnityEngine.InputSystem;
    6. //using UnityEngine.InputSystem.LowLevel;
    7.  
    8. public class HotKey_Change : MonoBehaviour
    9. {
    10.  
    11.     public TMPro.TMP_Text _buttonText;
    12.  
    13.     public InputActionReference m_ActionReference;
    14.  
    15.     //public InputActionAsset current_ActionAsset;
    16.  
    17.     public InputControlScheme? _controlScheme;
    18.  
    19.     private InputAction m_Action;
    20.  
    21.     private InputActionRebindingExtensions.RebindingOperation m_RebindOperation;
    22.  
    23.     private string clearedPath;
    24.     private string oldPath;
    25.  
    26.     private int _charIndex;
    27.  
    28.     private char _singleChar;
    29.  
    30.     //private Buttons_InGameMenu BIGM_script;
    31.  
    32.     private Player_Input plyInput_script;
    33.  
    34.     public bool _checkSomething = false;
    35.     public bool _isComposite = false;
    36.  
    37.     // Start is called before the first frame update
    38.     void Start()
    39.     {
    40.  
    41.         plyInput_script = FindObjectOfType<Player_Input>();
    42.         //BIGM_script = FindObjectOfType<Buttons_InGameMenu>();
    43.  
    44.         // The single char "/" we need for deleting the path to this point
    45.         _singleChar = '/';
    46.  
    47.         m_Action = m_ActionReference.action;
    48.  
    49.         PathToButtonLMPText();
    50.  
    51.         gameObject.GetComponent<Button>().onClick.AddListener(OnClickChangeKey);
    52.        
    53.         // For check something at the beginning
    54.         if (_checkSomething == true)
    55.         {
    56.  
    57.             //m_Action = m_ActionReference.action;
    58.  
    59.             //for (int i = 0; i < m_ActionReference.action.bindings.Count; i++)
    60.             //{
    61.  
    62.             //    Debug.Log(m_Action.bindings);
    63.  
    64.             //}
    65.  
    66.         }
    67.  
    68.     }
    69.  
    70.     private void OnDestroy()
    71.     {
    72.         m_RebindOperation?.Dispose();
    73.     }
    74.  
    75.     private void PathToButtonLMPText()
    76.     {
    77.  
    78.         // We check, if the action has more than 1 bindings
    79.         //if (m_ActionReference.action.bindings.Count > 1)
    80.         //{
    81.  
    82.             // We check every binding
    83.         for (int i = 0; i < m_Action.bindings.Count; i++)
    84.         {
    85.  
    86.             // We chose all bindings with the group "Keyboard&Mouse"
    87.             if (m_Action.bindings[i].groups.Contains("Keyboard&Mouse"))
    88.             {
    89.  
    90.                 // We check, if the gameobject (the button) has the bindings name in its own name
    91.                 if (gameObject.name.Contains(m_Action.bindings[i].name))
    92.                 {
    93.  
    94.                     if (m_Action.bindings[i].effectivePath != null)
    95.                     {
    96.  
    97.                         // We get the path of the binding
    98.                         clearedPath = m_Action.bindings[i].effectivePath;
    99.  
    100.                     }
    101.                     else
    102.                     {
    103.  
    104.                         clearedPath = m_Action.bindings[i].path;
    105.  
    106.                     }
    107.                     // We get the Index of the char "/" in the path
    108.                     _charIndex = clearedPath.IndexOf(_singleChar);
    109.  
    110.                     // Now we clear the name to the index of "/". Example: <Keyboard>/w -> w
    111.                     _buttonText.text = clearedPath.Remove(0, _charIndex + 1);
    112.  
    113.                 }
    114.  
    115.                 if (m_Action.bindings[i].name.Length !> 0)
    116.                 {
    117.  
    118.                     // We check, if the gameobject (the button) has the bindings name in its own name
    119.                     if (gameObject.name.Contains(m_Action.name))
    120.                     {
    121.  
    122.                         if (m_Action.bindings[i].effectivePath != null)
    123.                         {
    124.  
    125.                             // We get the path of the binding
    126.                             clearedPath = m_Action.bindings[i].effectivePath;
    127.  
    128.                         }
    129.                         else
    130.                         {
    131.  
    132.                             clearedPath = m_Action.bindings[i].path;
    133.  
    134.                         }
    135.                         // We get the Index of the char "/" in the path
    136.                         _charIndex = clearedPath.IndexOf(_singleChar);
    137.                         // Now we clear the name to the index of "/". Example: <Keyboard>/w -> w
    138.                         _buttonText.text = clearedPath.Remove(0, _charIndex + 1);
    139.  
    140.                     }
    141.  
    142.                 }
    143.  
    144.             }
    145.                 // TODO: GAMEPAD
    146.  
    147.         }
    148.  
    149.  
    150.     }
    151.  
    152.     private void OnClickChangeKey()
    153.     {
    154.  
    155.         for (int i = 0; i < m_Action.bindings.Count; i++)
    156.         {
    157.  
    158.             if (m_Action.bindings[i].groups.Contains("Keyboard&Mouse"))
    159.             {
    160.  
    161.                 // We check, if the gameobject (the button) has the bindings name in its own name
    162.                 if (gameObject.name.Contains(m_Action.bindings[i].name))
    163.                 {
    164.  
    165.                     ActiveChanging(i);
    166.                     //Debug.Log(m_ActionReference.action.bindings[i].path);
    167.  
    168.                 }
    169.  
    170.                 if (m_Action.bindings[i].name.Length !> 0)
    171.                 {
    172.  
    173.                     // We check, if the gameobject (the button) has the action name in its own name
    174.                     if (gameObject.name.Contains(m_Action.name))
    175.                     {
    176.  
    177.                         Debug.Log(m_Action.bindings[i].path);
    178.  
    179.                     }
    180.  
    181.                 }
    182.  
    183.             }
    184.  
    185.         }
    186.  
    187.     }
    188.  
    189.     private void ActiveChanging(int index)
    190.     {
    191.  
    192.         gameObject.GetComponent<Button>().enabled = false;
    193.         _buttonText.text = "Press Key";
    194.         m_RebindOperation?.Dispose();
    195.  
    196.         m_RebindOperation = m_Action.PerformInteractiveRebinding(index)
    197.             .WithControlsExcluding("<Mouse>/position")
    198.             .WithControlsExcluding("<Mouse>/delta")
    199.             .OnMatchWaitForAnother(0.1f)
    200.             //.WithTargetBinding(index)
    201.             .WithBindingGroup("Keyboard&Mouse")
    202.             .OnComplete(operation => ButtonRebindCompleted(index));
    203.  
    204.         m_RebindOperation = m_RebindOperation
    205.             .OnGeneratePath(x => "")
    206.             .OnApplyBinding((x, path) =>
    207.             {
    208.  
    209.                 m_Action.ApplyBindingOverride(index, new InputBinding { overridePath = path });
    210.  
    211.             }).Start();
    212.  
    213.        
    214.  
    215.     }
    216.  
    217.     void ButtonRebindCompleted(int index)
    218.     {
    219.         // Test of a more direct change -> not working
    220.         //plyInput_script._controls.Player.Fire.ApplyBindingOverride(bindingOverride: new InputBinding(m_Action.bindings[index].overridePath));
    221.  
    222.         m_RebindOperation.Dispose();
    223.         m_RebindOperation = null;
    224.  
    225.         PathToButtonLMPText();
    226.         gameObject.GetComponent<Button>().enabled = true;
    227.  
    228.         Debug.Log(m_Action.bindings[index].overridePath);
    229.         Debug.Log(m_Action.bindings[index].path);
    230.         Debug.Log(m_Action.bindings[index].effectivePath);
    231.  
    232.     }
    233.  
    234. }
    235.  

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.UI;
    5. using UnityEngine.InputSystem;
    6.  
    7. public class Buttons_InGameMenu : MonoBehaviour
    8. {
    9.  
    10.     // Panel Element
    11.     public GameObject _mainMenuPanel;
    12.     public GameObject _optionsPanel;
    13.  
    14.     // Buttons
    15.     public Button _back;
    16.     public Button _resume;
    17.     public Button _options;
    18.  
    19.     public InputActionAsset witchesInputActions;
    20.     private InputActionMap playerActionMap;
    21.  
    22.     // Start is called before the first frame update
    23.     void Start()
    24.     {
    25.  
    26.         playerActionMap = witchesInputActions.FindActionMap("Player");
    27.         _back.onClick.AddListener(Back);
    28.         _resume.onClick.AddListener(Resume);
    29.         _options.onClick.AddListener(Options);
    30.  
    31.     }
    32.  
    33.     void Back()
    34.     {
    35.  
    36.         playerActionMap.Enable();
    37.  
    38.         _optionsPanel.SetActive(false);
    39.         _mainMenuPanel.SetActive(true);
    40.        
    41.  
    42.     }
    43.  
    44.     void Resume()
    45.     {
    46.  
    47.         _mainMenuPanel.SetActive(false);
    48.  
    49.         Time.timeScale = 1;
    50.  
    51.     }
    52.  
    53.     void Options()
    54.     {
    55.  
    56.        
    57.         playerActionMap.Disable();
    58.  
    59.         _mainMenuPanel.SetActive(false);
    60.         _optionsPanel.SetActive(true);
    61.  
    62.     }
    63.  
    64. }
    65.  
     
  2. Thuztor

    Thuztor

    Joined:
    Sep 16, 2017
    Posts:
    5
    Thanks for unlock my post.
    Additionally to my post above:
    I've tested [Invoke Unity Events] and bind some events of my script to the "Player Input" - Component. Now the overrided bindings will be noticed, but additionally also the default binding, if I don't comment out these lines: example:
    Code (CSharp):
    1. //_controls.Player.Move.performed +=  HandleMove;
    But without adjustments this cause other problems in my scripts.

    I'm missing something fundamental, I think. o_O

    I'm not quite sure, if it's important, but Input Debug is not able to perform "Enable Event Diagnostic".
    On every pushed key, I got an error message. -> Maybe, because I'm using a HID-Keyboard?
     
    Last edited: Apr 14, 2021
  3. Thuztor

    Thuztor

    Joined:
    Sep 16, 2017
    Posts:
    5
    If someone is interested in.
    I've changed follow things, so that it works now:

    - I've put my generated "InputActionAsset" in a separate asset variable.[Player_Input.cs]
    - Changed the access of the performed line:

    Code (CSharp):
    1. //From this
    2.         //_controls.Player.Move.performed +=  HandleMove;
    3.         //to this
    4.         IAAsset.actionMaps[0].FindAction("Move").performed += HandleMove;
    - In the Hotkey_Change.cs script, I've just replace some fixed actions:

    Code (CSharp):
    1. //m_Action.ApplyBindingOverride(index, new InputBinding { overridePath = path });
    2.                 _IIAsset.actionMaps[0].FindAction(m_Action.name).ApplyBindingOverride(index, new InputBinding { overridePath = path });
    - Finally I've changed the deactivating/activating of the specific action map in Buttons_InGameMenu.cs
     
    Last edited: Apr 14, 2021
    Whatever560 likes this.