This is the second part of a series see https://peted.azurewebsites.net/hololens-end-to-end-in-unity/ Steps to create the demo project that I used in my Future Decoded UK 2016 presentation
Gaze is a way to direct your attention in the HoloLens environment – think of it as a mouse cursor but it is directed by the orientation of your head (not your eyes). This does take a short period of time to become accustomed to but then feels pleasingly natural thereafter. In order to understand at which point we are gazing at it is useful to have some kind of a visualisation and for the demo I used a cursor which is supplied as a prefab in the HoloToolkit.
To get set up with the HoloToolkit in Unity see https://mtaulty.com/2016/11/10/hitchiking-the-holotoolkit-unity-leg-1/
The BasicCursor prefab consists of a mesh, a shader (for the shadow) and a script to position the cursor.
The BasicCursor script depends on having a GazeManager instance. In order to achieve this you can create an empty game object (I usually rename this Managers) in your scene, find the GazeManager script in the HoloToolkit (Tip: use the project pane search box) and drag the GazeManager script onto your empty game object. This will ensure that the code inside the GazeManager script is executed at runtime and the BasicCursor script will be able to correctly reference the GazeManager instance.
The GazeManager keeps track of the first object hit by the vector with origin at the users head position and in a direction in which the head is pointing.
The BasicCursor script positions and orients its cursor mesh according to the hit object as tracked by the GazeManager. Its position is set to the hit location and the orientation is set in the direction of the normal at the hit point on the mesh.