Input System 1.3.0 released: more fixes

Hello again,

the 1.3.0 package of the Input System is now publically available. It contains mainly more bug fixes. Please see the Changelog for details.

It will be made available over time via the package manager as usual, but if you want it right now please add it manually by either editing the manifest or via the Add Packge by Name+Version in the newer tech releases.

Please do keep the feedback coming. It is very much appreciated even when we can't get to all of it right away.

10 Likes

Hey I still have this issue,

https://discussions.unity.com/t/867787
Do you know how to resolve this :) ?

I have a question using InputAction Callback Context that comes from the IActions interface generated by
an input asset.

The Callback Context doesn't update when holding the button. It calls during started, performed, cancelled.
Any way to get this to work with holding a button to keep it firing the functions called inside of the context.

1 Like

Any idea why this new release is not visible in the package manager for 2021 unity ?

1 Like

[quote=“blackmodjo”, post:4, topic: 867723]
Any idea why this new release is not visible in the package manager for 2021 unity ?
[/quote]
Because it is not validated yet. You can install it manually through the Add package by name option.

2 Likes

Is there anything planed for continuous input support for the PlayerInput component.
I really like using C# classes (it's way better that having to write the name of the input with a string) but using a component without any programming seems really cool and would be great for beginners.
But right now it's not that useful since it's only working for things like a jump or an interaction not for movement.

Will there be an update to add that ?
(very sorry for my English)

How to check if any key on any connected device was pressed? I can't find an API for that. It was planned for beyond 1.0 as you can see in this post . Is there an easy/convenient way to do it?

[quote]
How to check if any key on any connected device was pressed? I can't find an API for that. It was planned for beyond 1.0 as you can see in this post . Is there an easy/convenient way to do it?
[/quote]
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.3/manual/HowDoI.html#wait-for-any-button-to-be-pressed-on-any-device

1 Like

[quote]
How to check if any key on any connected device was pressed? I can't find an API for that. It was planned for beyond 1.0 as you can see in this post . Is there an easy/convenient way to do it?
[/quote]

Hey you are looking for the anyKey method.

Go to the documentation below and look for anyKey. See if that is what you are looking for.
It returns 1 if pressed and 0 if no keys are pressed.
I think you can also do the anyKey.wasPressedThisFrame and anyKey.wasPressed.

https://docs.unity3d.com/Packages/com.unity.inputsystem@1.3/api/UnityEngine.InputSystem.Keyboard.html#UnityEngine_InputSystem_Keyboard_anyKey

Can anyone give an example on how to use this? The docs are not so clear for me .. a code example is the best go! Thanks.

[quote]
to use this
[/quote]
"this" what exactly? You got two solutions with vastly different purpose and behavior. Which one are you talking about?
[quote]
a code example is the best go
[/quote]
My link which is a method to actually monitor all devices and all buttons has a code example on the link I provided. The other one which only monitors the keyboard is super simle: if (Keyboard.current.anyKey.wasPressedThisFrame) doSomething;

[quote]
Because it is not validated yet. You can install it manually through the Add package by name option.
[/quote]
I tried but it doesn't work when you search for Input System or InputSystem or input system i tried also the git url https://github.com/Unity-Technologies/InputSystem.git and i get back the error that the error that it is missing the manifest, i even tried https://github.com/Unity-Technologies/InputSystem/tree/develop/Packages/com.unity.inputsystem

[Package Manager Window] Cannot perform upm operation: Unable to add package [https://github.com/Unity-Technologies/InputSystem/tree/develop/Packages/com.unity.inputsystem]:
Package name 'https://github.com/Unity-Technologies/InputSystem/tree/develop/Packages/com.unity.inputsystem' is invalid. [InvalidParameter].
UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()

[quote=“blackmodjo”, post:12, topic: 867723]
I tried but it doesn’t work when you search for Input System or InputSystem or input system i tried also the git url https://github.com/Unity-Technologies/InputSystem.git and i get back the error that the error that it is missing the manifest, i even tried https://github.com/Unity-Technologies/InputSystem/tree/develop/Packages/com.unity.inputsystem

[Package Manager Window] Cannot perform upm operation: Unable to add package [https://github.com/Unity-Technologies/InputSystem/tree/develop/Packages/com.unity.inputsystem]:
Package name 'https://github.com/Unity-Technologies/InputSystem/tree/develop/Packages/com.unity.inputsystem' is invalid. [InvalidParameter].
UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()

[/quote]
Here is step by step, obviously you need to use the proper version number:
https://discussions.unity.com/t/849046/2

This is how I'm trying to do it, but it doesn't work:

using UnityEngine;
using UnityEngine.InputSystem;
public class NewBehaviourScript : MonoBehaviour
{
    private void Update()
    {
        var myAction = new InputAction(binding: "/*/<button>");
        myAction.onPerformed += (action, control) => Debug.Log($"Button pressed!");
        myAction.Enable();
    }
}

When I press any key, it doesn't print anything in the Console.

Tried second method as well, but I can't seem to figure it out as there is a persistent error .. here's the code:

using UnityEngine;
using UnityEngine.InputSystem.Controls;
public class NewBehaviourScript : MonoBehaviour
{
    private AnyKeyControl anyKey;
    private void Awake()
    {
        anyKey = new AnyKeyControl();
    }
    private void Update()
    {
        if (anyKey.wasPressedThisFrame)
        {
            print("Pressed!");
        }
    }
}

7856872--997324--Screenshot 2022-02-01 020142.png

Error

I don't know what am I doing wrong and what this error means .. I'm still fairly new to Unity and just learning the Input System and coding in general. If you could provide a practical example, it would be so helpful and insightful. Thanks again. :)

[quote]
When I press any key, it doesn't print anything in the Console.
[/quote]

using UnityEngine;
using UnityEngine.InputSystem;

public class NewBehaviourScript : MonoBehaviour
{
    private readonly InputAction _anyKeyWait = new(binding: "/*/<button>");

    private void Awake() => _anyKeyWait.performed += DoSomething;
    private void OnEnable() => _anyKeyWait.Enable();
    private void OnDisable() => _anyKeyWait.Disable();
    private void OnDestroy() => _anyKeyWait.performed -= DoSomething;

    private void DoSomething(InputAction.CallbackContext ctx) => Debug.Log("'Any' button pressed.");
}
4 Likes

I tried the code you posted, and it works like a charm. However, there's just a tiny problem with it: If you press 'any' key, it will register it, However, once you release it, it will register it Yet Again as well! So, the action is triggered Twice! I'm sorry if I'm annoying you, but how to just do it on 'press' without 'release'? Thanks for the code and your help btw :)

[quote]
I tried the code you posted, and it works like a charm. However, there's just a tiny problem with it: If you press 'any' key, it will register it, However, once you release it, it will register it Yet Again as well! So, the action is triggered Twice! I'm sorry if I'm annoying you, but how to just do it on 'press' without 'release'? Thanks for the code and your help btw :)
[/quote]
Replace
private readonly InputAction _anyKeyWait = new(binding: "/*/<button>");
with
private readonly InputAction _anyKeyWait = new(binding: "/*/<button>", type:InputActionType.Button);

https://docs.unity3d.com/Packages/com.unity.inputsystem@1.3/manual/Interactions.html#predefined-interactions

2 Likes

Yes, now it works as expected. Thank you so much for your generous help :smile:

There's another way to detect 'any' key, here's some code if anyone is interested:

using UnityEngine;
using UnityEngine.InputSystem;
public class Test : MonoBehaviour
{
    private readonly InputAction anyKey = new(binding: "/*/<button>", type: InputActionType.Button);
    private void Update()
    {
        if (anyKey.triggered)
        {
            print("'Any' button pressed");
        }
    }
    private void OnEnable()
    {
        anyKey.Enable();
    }
    private void OnDisable()
    {
        anyKey.Disable();
    }
}
2 Likes

I had a great dream once. It looked something like this:

7859059--997726--upload_2022-2-1_12-24-37.png

3 Likes