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.

Can't create List of InputActions

Discussion in 'Input System' started by raphael_kox, Dec 28, 2021.

  1. raphael_kox


    May 1, 2019
    I'm trying to create a list of input actions, but when adding a new element to the list
    it's "bound" to the existing element (the first on the list), and any change made to it
    is reflected on all the items.

    I tried to create elements with different names in the script (as I thought that
    was the problem) like so:

    Code (CSharp):
    1. public List<InputAction> Inputs = new List<InputAction>() {
    2.     new InputAction("ActionA"),
    3.     new InputAction("ActionB"),
    4. }
    and they are created with the name of first element, like if a "copy".
    The result was the image attached (all the items with the same name ActionA)

    I even tried GUIDs, and creating the items outside the inspector by code
    and the problem persists. Every new item created is a copy of the first.

    Anyone had the same problem or could help me understand if that is not possible
    (I can't see why, as you can create separate InputAction variables and they work fine)
    or probably a bug.

    Thanks in advance!

    Attached Files: