Search Unity

Question Persistent Rebinding with C# generated script

Discussion in 'Documentation' started by udemyrootgames, May 7, 2022.

  1. udemyrootgames

    udemyrootgames

    Joined:
    Aug 3, 2021
    Posts:
    15
    Is it possible to create persistent rebinding using C# generated script? Here is an example of code:
    Code (CSharp):
    1. public class PlayerControls : MonoBehaviour
    2. {
    3.     private Controls _controls;
    4.     void Awake()
    5.     {
    6.          _controls = new Controls();
    7.         _controls.Enable();
    8.      
    9.     }
    10.  
    11.     private void OnEnable()
    12.     {
    13.         _controls.Player.Jump.performed += DoJump;
    14.     }
    15.     private void OnDisable()
    16.     {    
    17.         _controls.Player.Jump.performed -= DoJump;
    18.     }
    19.  
    20.  
    21.     private void DoJump(InputAction.CallbackContext value)
    22.     {
    23.        
    24.         Debug.Log("Player jumps");
    25.     }
    26.    
    27. }
    28.  
    I use C# generated script and "Send Messages" option in the PlayerInput component. I want to rebind the button for the Jump action.
    InputActions.png
    Any references or examples for this situation? I can only find persistent rebinding when not using C# generated script.
    Also, I use version 1.3 of the Input System package.
     
  2. udemyrootgames

    udemyrootgames

    Joined:
    Aug 3, 2021
    Posts:
    15
    This thread is placed in the wrong place by mistake, please delete it, I will post it in the Input System.