I stumbled upon this pretty annoying bug today, when using 1+ more buttons Composites with the Hold interaction.
Tested it with 1, 2 and even 3 buttons composites (for the latter I wrote a custom class in order to add the option in the Inspector), and it shows up regardless of the devices used (pad/keyboard/mouse/mix of the formers).
My setup is this -
First, a simple script to be attached to any game object:
using UnityEngine;
using UnityEngine.InputSystem;
public class InputTest : MonoBehaviour {
[SerializeField]
private InputAction TestAction;
private void Awake() {
TestAction.started += context => Debug.Log($"Started {context.action.name} at {context.time}");
TestAction.performed += context => Debug.Log($"Performed {context.action.name} at {context.time}");
TestAction.canceled += context => Debug.Log($"Canceled {context.action.name} at {context.time}");
}
private void OnEnable() {
TestAction.Enable();
}
private void OnDisable() {
TestAction.Disable();
}
}
Second, the bindings I created on the component:
Third, the action itself is set to Button and the Hold interaction added, with a Hold Time of 2 seconds.
With all the setup ready, when you enter play mode, if you press one of the buttons of the composite and then the other one (while holding the first one pressed), everything works fine, the started
callback is called first, then the performed
one (if you keep them pressed over 2 secs) and finally the canceled
one.
But, if you press both buttons simultaneously (at least, as far as a human can do that) and release them before the hold time is passed, this is what happens:
The first two callbacks are correct, they get called when I press and then release both buttons simultaneously.
Then, after an amount of time equal to start_time + hold_time, and without me using any device at all, the started
callback is called again, immediately followed by the performed
callback, and the last canceled
callback is called only if and when I press one of the buttons of the composite.
I tried a lot of different setups (using an Action Map from an Input Asset, creating the binding via code, setting the Hold interaction in the Bindings instead of the parent Action, etc.), and nothing seemed to fix this.
Edit: forgot to say that this happens on 2019.3.13f1 and .14f1, with the 1.0.0 package.