- Home /
Can't create list of InputActions
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) and they are created with the name of first element, like if a "copy".
Like so:
public List<InputAction> Inputs = new List<InputAction>() {
new InputAction("ActionA"),
new InputAction("ActionB"),
};
The result was:
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!
Answer by GintarasOE · Dec 29, 2021 at 07:37 PM
Hi,
This seems to be a Unity bug documented here: https://issuetracker.unity3d.com/issues/adding-a-binding-to-one-inputaction-element-in-a-list-adds-the-same-binding-to-all-the-other-elements-in-the-list
The fix is already released in newest InputSystem package versions. So you can consider updating InputSystem package and the issue should be gone. Tested with Unity 2022.1.0b2 and InputSystem package version 1.2.0 it seems that fix is indeed working (although there's some other graphical issues but not as severe and may be caused by 2022.1.0b2 not the InputSystem package itself).
Of course would suggest making a full backup of your project before updating (you never know what may go wrong).
Your answer
Follow this Question
Related Questions
Help In Making a SphereCast for 3D Tire! Working RayCast Script included! 0 Answers
Backspace in limited length textfield causes ArgumentOutOfRangeException 1 Answer
My Players speed differs depending on the input method (gamepad or keyboard) 1 Answer
Cross-Platform User-Defined Keys? 0 Answers
How can I retrieve the Axis/Button list programmatically? 2 Answers