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.
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.
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?
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.
“this” what exactly? You got two solutions with vastly different purpose and behavior. Which one are you talking about?
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;
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!");
}
}
}
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.
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