Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Question New Input System - How to load from JSON a wrapper generated from an inputActions asset?

Discussion in 'Input System' started by Lordscales91, Jun 16, 2020.

  1. Lordscales91

    Lordscales91

    Joined:
    Sep 30, 2018
    Posts:
    12
    Hi there! I'm learning the new input system and there's a detail I don't understand. When you check the "Generate C# class" in the inspector, a wrapper class is automatically generated for you from the inputActions asset. This wrapper generates some useful shortcuts, which is good. But what happens if I want to allow the user to rebind the default mappings? The users won't be happy if they had to rebind the controls every time they start the game, so obviously I would persist those changes to a JSON file and load it the next time the game starts.

    I know I can load it as an InputActionAsset, or a list of InputActionMaps, but the generated wrapper doesn't provide any constructor to fed an externally loaded InputActionAsset. I could maybe create a subclass of it, but that doesn't seems right.

    Any suggestions?
     
  2. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    I've posted some information for how to save and restore rebinds here.

    APIs to simplify and help with this are coming in 1.1.
     
  3. Lordscales91

    Lordscales91

    Joined:
    Sep 30, 2018
    Posts:
    12
    Oh! Now I understand why I was stuck with this. I couldn't find information about it anywhere.

    Thank you very much!