MixedRealityToolkit-Unity icon indicating copy to clipboard operation
MixedRealityToolkit-Unity copied to clipboard

PressableButton gets stuck in touched/pressed state if disabled while touched/pressed

Open mrbobbybobberson opened this issue 7 years ago • 6 comments

Overview

In my project, we have buttons that, when pressed, end up causing themselves to be disabled. For example, we have a TextMeshPro explaining what kind of test the user is about to go through, and there's a "Begin" button under it. When the user presses "Begin", the parent game object of all that UX gets set inactive to hide it, and the user goes through the testing process.

Later, we reenable the UX to give the user a break and explain what the next test will be. When the UX is reenabled, the "Begin" button still has stale touchPoints in it from when it got disabled, so it thinks it's still currently touched and pressed.

If the user has kept his/her hand up the whole time and interacts with the button again, the button can recover, since it sees the new touches as updates to the old one, but if the user has lowered and raised his/her hand, MRTK and the button will consider the new touches as though they're coming from a unique controller, and the old touch will be stuck in the button forever, so it will stay in the pressed state forever, and can't trigger its pressed events again.

I worked around the issue by adding the following code to PressableButton, but I didn't test it exhaustively, and I don't know if it's the right fix given the bigger picture of MRTK input:

protected void OnDisable()
{
	touchPoints.Clear();
	IsTouching = false;
	isPressing = false;
}

Expected Behavior

I would expect PressableButton to come back without any touch state when it's reenabled.

Actual Behavior

PressableButton gets stuck in the touched/pressed state and can't be pressed again.

Steps to reproduce

  1. Make a PressableButton in a scene.
  2. Hook it up so that when you press the pressable button, it or its parent game object gets set inactive thereby hiding the button.
  3. Press the button with your finger (ie: direct manipulation touch)
  4. While the button is hidden, lower your hand.
  5. Do something to reenable the button (like make it automatically reenable after a period of time or use a Bluetooth mouse or keyboard or voice command to set the game object active again. [BUG] If you have logging or a debugger attached, you'll see that it's in the touched/pressed state when it comes back, even though nothing is touching it.
  6. Now raise your hand and try to touch the button again. [BUG] It won't be pressable anymore, because it's already stuck in the pressed state.

Unity Editor Version

Same steps as above, but use the editor simulation hand. Remember "raising" and "lowering" your editor hand is done by pressing or releasing the right keyboard button (e.g. the Shift button).

Mixed Reality Toolkit Release Version

v2.0.0-RC1-Refresh

mrbobbybobberson avatar May 22 '19 19:05 mrbobbybobberson

I've also encountered this when focusing targets with other inputs (head, eyes, hand ray):

  1. Focus at a target
  2. Disable the target while still focusing it
  3. Reenable the target not focusing on it and it will still have the old focuser in its list.

The problem is how input events are routed to game objects when they or their parent get disabled (e.g., via SetActive(false)).

sostel avatar May 22 '19 19:05 sostel

This has been fixed in mrtk_dev.

julenka avatar May 31 '19 21:05 julenka

Hello @julenka I tried in mrtk release branch with a pressableround button. When we disable the button on click and reenable it, the button is enabled in focused state (atleast visually). Is that expected behavior?

shubham-bitsnbytes avatar Jun 21 '19 14:06 shubham-bitsnbytes

Hi @thalbern Did you get time to look into this issue? Any workaround for us?

shubham-bitsnbytes avatar Jul 02 '19 09:07 shubham-bitsnbytes

Looking at it now. tagging GA blocker as well

Yoyozilla avatar Aug 01 '19 08:08 Yoyozilla

@Shubham7694 sry for not coming back to this earlier. I just had a look at it and need some more info to understand this correctly. the original issue was that the user wouldn't be able to interact anymore with the button after setting it active again. Does that still happen?

I'm currently only seeing a visual glitch in my review that shows the button as highlighted, but it's still functional?

(looking at the visual glitch now)

thalbern avatar Aug 01 '19 11:08 thalbern