Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

[Help] Input system assert when saving rebinds

Discussion in 'Input System' started by Deleted User, Oct 12, 2021.

  1. Deleted User

    Deleted User


    So I'm using the following code to load input actions on Start and save whenever a binding is rebound. I am using the code from this previous post: But whenever I rebind a key and SaveKeybinds gets called called I get the following exception


    This is also accompanied by failing to load keybinds on start. Heres the code I use:

    Code (CSharp):
    1.     [SerializeField] InputActionAsset inputAsset;
    2.     [SerializeField] List<RebindActionUI> rebindUis;
    4.     void Start()
    5.     {
    6.         LoadKeybinds();
    8.         foreach (var rebind in rebindUis)
    9.             rebind.stopRebindEvent.AddListener(SaveKeybinds);
    10.     }
    12.     void SaveKeybinds(RebindActionUI ui, InputActionRebindingExtensions.RebindingOperation opr)
    13.     {
    14.         var rebinds = inputAsset.ToJson();
    15.         PlayerPrefs.SetString("Rebinds", rebinds);
    16.     }
    18.     void LoadKeybinds()
    19.     {
    20.         var rebinds = PlayerPrefs.GetString("Rebinds");
    22.         if (!string.IsNullOrEmpty(rebinds))
    23.             inputAsset.LoadFromJson(rebinds);
    24.     }
    Is this an issue with my setup or is it a Unity issue? Thanks.