Hello everyone.

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.

Origami Tutorial Gaze Gesture Manager : help deconstructing Start() script

Hello all (and hopefully @Alex ),

I have the Origami tutorial working but I'm not able to wrap my head around whats happening in the Start() function of the Gaze Gesture Manager script.
I have a few questions that I feel will help portray what I'm struggling with.
Appreciate your help.

Q: How is public GameObject FocusedObject being used
Q:How did Unity manage to Divine if FocusedObject was Null or not (it is not being explicitly set afaik)
Q:What happens when the script runs (via Start() ) the first time
Q: How is instance = This being used

Thank you so much for any help.

` using UnityEngine;
using UnityEngine.VR.WSA.Input;

public class GazeGestureManager : MonoBehaviour
    public static GazeGestureManager Instance { get; private set; }

    // Represents the hologram that is currently being gazed at.

    public GameObject FocusedObject { get; private set; }

    GestureRecognizer recognizer;

    // Use this for initialization
    void Start()
        Instance = this;

        // Set up a GestureRecognizer to detect Select gestures.
        recognizer = new GestureRecognizer();
        recognizer.TappedEvent += (source, tapCount, ray) =>
            // Send an OnSelect message to the focused object and its ancestors.
            if (FocusedObject != null)

    // Update is called once per frame
    void Update()
        // I think I understand this part




Best Answers


  • behrambehram
    edited June 2016

    Ok so my misunderstanding was that anything setup in the Start function happens once and only once. Wrong !
    The TappedEvent Event Handler is only set in motion in the Start function and persists even after the Start function.Which is what @neerajwadhwa was trying to get across above.

    The penny dropped when the folks at Unity chimed in.

    End Update_1

    Thanks for the reply Neeraj,
    I will write my understanding of what I think is happening and hopefully you can correct any misconception / ignorance on my part. I think my understanding of Events and how unity handles them is a bit lacking.

    1.When the game begins and Unity runs the Gaze Gesture Manager script
    2. public GameObject FocusedObject variable is declared (which defaults to Null ?)
    3. Since there is no Awake function, the Start function is executed once and "only" once during the lifetime of the Program.
    3. in the event handler we check for FocusedObject to have a valid value (i.e not Null)
    4. Since this is the first time the script is being run FocusedObject is indeed Null ?
    5. Therefore SendMessageUpwards("OnSelect") is never executed !
    That is what I'm having trouble understanding.

    Can we try to deconstruct the process once more ?

  • Hi guys,

    I'm also having a bit of trouble figuring out the start script. This post has been very helpful, thank you for the answers @neerajwadhwa . I have more of my own however... mostly I just don't understand why recognizer.StartCapturingGestures() is after the recognizer.TappedEvent. Obviously it works this way, I know it's correct, but thinking it through with my understanding as it is now, I would think that the GestureRecognizer would need to "start capturing gestures" before it can be aware of a tapped event happening... if that makes sense...

    Does the line " recognizer.TappedEvent += (source, tapCount, ray) =>" just set up what will happen WHEN the GestureRecognizer captures a tapped event, and then the line "recognizer.StartCapturingGestures();" actually tells the GestureRecognizer to begin to watch out for gestures? Or am I completely off base here?

    Thanks so much for any help!!

  • @ckesterson I think about it this way:

    Why start capturing the gestures without having something that actually handles that gesture. Hence I think the order of register and capture makes sense to me.

  • That makes a lot of sense when you put it that way. Thank you so much for your help!

Sign In or Register to comment.