MixedRealityInputSystem does not handle Focus events correctly
Overview
Any Interactable component will suffer from incorrect handling of Focus events. If more than one pointer is involved (gaze and controller), a successful exit depends on the order the pointers enter and exit.
- The MixedRealityInputSystem will only ever call FocusEnter once on a gameobject, regardless of how many pointers entered it (pendingOverallFocusEnterSet makes sure of that). This fact makes the whole Pointer counting in the Interactable class useless.
- AddPointer and RemovePointer in the Interactable class add and remove first comes first serve. That means, if you exit focus with the pointer that entered second or later, OnFocusExit won't be called.
Either MixedRealityInputSystem calls Enter and Exit for EACH cursor, or Interactable cannot rely on a specific cursor that entered and exited.
Expected Behavior
OnFocusExit always works
Actual Behavior
It does not always work
Steps to reproduce
- Gaze at an Interactable object
- Point at it with the controller
- Move the controller away
- Look away
The interactable stays in the selected state
Unity Editor Version
2018.3.7f1
Mixed Reality Toolkit Release Version
mrtk_development
@davidkline-ms I think this is a problem and worth a discussion: It could be desirable to receive all Focus events for the pointers (need two for twohand activation for example; the current Interactable already tries to count all pointers, but won't receive any more than one). If the InputSystem was to be changed in that way, it's a question of how to handle that in an Interactable. You might want to have the choice between single focus events or every single event. This would either mean that the Interactable component needs to properly count the cursors which deriving classes can check, or using the template pattern and seal the actual Focus calls and providing apropriate methods instead. But that would mean the interface would not work anymore. What do you think? I'd go with the former.
this goes even further. inputs also have down and up. so there's a few state toggles three and the question is if they all should reliably work for each input device instead of just happening once? I'm not even sure if down and up are called for each already. the receiving component should handle how it wants to react.
@alexees, thank you for the feedback! we had presumed that developers would desire only one focusenter event.
We will take a look at this for the upcoming (by end of March) release.
@davidkline-ms I don't need one. But dependent on the decision, the Interactable bug has to be fixed or will fix itself.
It's not even that simple. When I gaze on a button AND point at it, I expect it to highlight on first enter and return on last exit. If there's just one enter and exit each, the InputSystem needs to count the pointers to make sure this is happening. And if it does, there's no reason to make the choice of receiving all or just one of each call.
@Alexees , can we close this one?
@luis-valverde-ms sure, that's quite an old one