Disabling action while button is pressed breaks functionality
When disabling an action via a button press, the input is not functional after re-enabling. Even though the action is present in the Input Debugger.
I have attached a sample MonoBehaviour, which demonstrates the issue while attempting to re-enable via the Update loop or via a Coroutine.
I have also been able to trigger this issue, by disabling the action by manually disabling a MonoBehaviour which calls Action#Enable/Disable, via OnEnabled/OnDisabled calls respectively.
This issue is present in 0.2.6-preview, and appears to still be present in the latest commit in today's develop branch. This is with Unity 2019.1.0 (RC) on Mac, using PS4 and XBox 360 joypads.
As a side-issue, I've also noticed that InputAction.CallbackContext control value is inaccessible after an action is disabled.
void Action_Performed(InputAction.CallbackContext ctx)
{
Debug.Log($"Control: {ctx.control.name}");
action.Disable();
// FIXME ctx.control throws IndexOutOfRangeException.
Debug.Log($"Control: {ctx.control.name}");
...
I have strong suspicion this is a regress for this: https://issuetracker.unity3d.com/issues/scripting-input-action-loses-callback-functions-after-re-enabled
This is indeed a regressed bug. Re-open. Feel free to vote at: https://issuetracker.unity3d.com/issues/scripting-input-action-loses-callback-functions-after-re-enabled
Thanks for your review. I have voted.
Never mind. This issue is not the same as the one I listed above. It is hard to tell what stops the Action from re-enabling, considering one is via coroutine and the other just a count down in Update, so it is not the same as #517. I file a new one for this. Feel free to vote here: https://issuetracker.unity3d.com/product/unity/issues/guid/1147560/
Thanks again.
I have noticed that my sample code functions correctly with the latest codebase from the develop branch, i.e. commit d6d3d3285ea0d6f3690aa8f3f5b8ed2b64ec2a35. (N.B. this issue is still present in the stable 0.2.8-preview)
However, if I add an interaction to the action constructor, e.g.
action = new InputAction("Any button press", "<Gamepad>/<Button>", "Press");
or
action = new InputAction("Any button press", "<Gamepad>/<Button>", "tap");
then the action seems to become functional after delay of a second or so, after being enabled. So it's certainly an improvement, but still persisting.
Tested in Unity 2019.1.0f2 (MacOS)