The Mixed Reality Forums here are no longer being used or maintained.
There are a few other places we would like to direct you to for support, both from Microsoft and from the community.
The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.
For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.
If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.
And always feel free to hit us up on Twitter @MxdRealityDev.
Issues with Gestures (GazeGestureManager)

I'm trying to get two different behaviors to work when looking at two different objects. Right now I have a GameObject that consists of 2 different 3D objects. Each 3D object has a GazeGestureManager (called PlayPauseGestureManager and RewindGestureManager) which I copied from the code in 100E, but changed the method to where it goes (i.e. from OnSelect to OnPlayPause and OnRewind).
In a different script, I implement these two behaviors in a script called PlayCommands. However, when I click on either object, I get the same behavior. I was debugging when clicking on the object for rewinding and it went to the RewindGestureManager and to the proper method (OnRewind) in PlayCommands, but then it goes to PlayPauseGestureManager, thereby implementing the OnPlayPause from PlayCommands and overriding OnRewind.
I'm not sure why this might be happening - does anyone know and may be able to help me fix it?
Best Answers
-
james_ashley ✭✭✭✭
It's hard to know for sure without seeing your code.
One thing I noticed, though, is that you are putting your two managers on the objects. This isn't the right pattern -- and possibly that's why you are having problems. There should be only one GazeGestureManager, it should be a singleton, and it should hang off of an empty gameobject called Managers. The GazeGestureManager should route the tapped event to an OnSelect method on the object you are gazing at. Then on one object you should have a MonoBehaviour called RewindBehaviour with the OnSelect method, while the other should have a PlayPauseBehaviour MonoBehaviour with OnSelect. I think if you follow that pattern, things will work much better. Make sense?
recognizer.TappedEvent += (source, tapCount, ray) =>
{
// Send an OnSelect message to the focused object and its ancestors.
if (FocusedObject != null)
{
FocusedObject.SendMessageUpwards("OnSelect");
}
};
recognizer.StartCapturingGestures();James Ashley
VS 2017 v5.3.3, Unity 2017.3.0f3, MRTK 2017.1.2, W10 17063
Microsoft MVP, Freelance HoloLens/MR Developer
www.imaginativeuniversal.com5 -
TRR ✭
@james_ashley Thank you for your response - that definitely makes sense and was something I thought about, but how does it distinguish between two different "Focused Objects"? How would it know whether to implement "FocusedObject.SendMessageUpwards("OnRewind")" or FocusedObject.SendMessageUpwards("OnPlayPause") ?
5
Answers
It's hard to know for sure without seeing your code.
One thing I noticed, though, is that you are putting your two managers on the objects. This isn't the right pattern -- and possibly that's why you are having problems. There should be only one GazeGestureManager, it should be a singleton, and it should hang off of an empty gameobject called Managers. The GazeGestureManager should route the tapped event to an OnSelect method on the object you are gazing at. Then on one object you should have a MonoBehaviour called RewindBehaviour with the OnSelect method, while the other should have a PlayPauseBehaviour MonoBehaviour with OnSelect. I think if you follow that pattern, things will work much better. Make sense?
recognizer.TappedEvent += (source, tapCount, ray) =>
{
// Send an OnSelect message to the focused object and its ancestors.
if (FocusedObject != null)
{
FocusedObject.SendMessageUpwards("OnSelect");
}
};
recognizer.StartCapturingGestures();
James Ashley
VS 2017 v5.3.3, Unity 2017.3.0f3, MRTK 2017.1.2, W10 17063
Microsoft MVP, Freelance HoloLens/MR Developer
www.imaginativeuniversal.com
@james_ashley Thank you for your response - that definitely makes sense and was something I thought about, but how does it distinguish between two different "Focused Objects"? How would it know whether to implement "FocusedObject.SendMessageUpwards("OnRewind")" or FocusedObject.SendMessageUpwards("OnPlayPause") ?
Oh wait, I just realize I did it backwards - I put a set of commands in one script and had multiple gesture managers for each object. What I should have done, which now works, is to create one gesture manager and multiple command scripts for the specific objects