Unity Input System uses incorrect input action when changing action map & calling an action with the same name

Bonfyre

New member
As title suggestions the input is incorrect for me if the name matches, for example I have Gameplay/Mouse X which I use, then when I switch action map to UI I also have UI/Mouse X. In UnityInputSystem it uses the action key without any context to its action map. Meaning I get Gameplay/Mouse X rather than UI/Mouse X (which is always 0 since Gameplay is not active).

Example when I'm calling playerInput.GetAxis("Mouse X")

I solved it by marking the method protected virtual and then using the fully qualified name:
C#:
protected override InputAction GetActionByName(string name) {
    string prefix = m_PlayerInput.currentActionMap?.name;
    string fqn = prefix + "/" + name;

    if (!m_ItemActionByName.TryGetValue(fqn, out var itemAction)) {
        itemAction = m_PlayerInput.currentActionMap?.FindAction(name);
        m_ItemActionByName.Add(fqn, itemAction);
    }

    return itemAction;
}

There is likely a better way to handle this, but it solves the issue for me.
 
Last edited:
Thank you for letting us know. I'm glad you found a solution that works for you.
We're looking into a more robust solution. Once we do we'll update the integration package
 
Top