#Hololens – How to detect AirTap and Click actions using #HoloToolkit (updated!)


During the last few months, HoloToolkit has evolved a lot. Some of the changes in the Toolkit make some of my blog samples as non-valid. For example, basic actions such as detecting an AirTap. In today’s post, I’ll quickly explain how to implement the AirTap or Click.

We start with the basics with these steps

  • Create a 3D project in Unity3D
  • Configure project to support HoloLens projects
  • Clean Scene elements
  • Import HoloToolkit package
  • Add
    • HololensCamera
    • SpatialMapping
    • CursorWithFeedback
  • Add Empty element, Managers
    • Add existing scripts
      • Gaze Managers
      • Gaze Stabilizer
      • Input Manager
  • Add Empty element, HoloCollection
    • Add 3D elements
      • Cube
        • Position, x:0 y:0 z:2
        • Rotation, x:0 y:0 z:0
        • Scale, x:0.3 y:0.3 z:0.3

This is the basic process to create a Hololens project in Unity3D.  Now let’s associate a script to the Cube that detects some user actions of the user, such as for example the AirTap. For this example, I will call the script “CubeManager.cs“. This is the source code of the script:

using HoloToolkit.Unity.InputModule;
using UnityEngine;

public class CubeManager : MonoBehaviour, IInputClickHandler, IInputHandler
  public void OnInputClicked(InputClickedEventData eventData)
    // AirTap code goes here
  public void OnInputDown(InputEventData eventData)
  { }
  public void OnInputUp(InputEventData eventData)
  { }

To capture AirTaps actions, we need to implement the “IInputClickHandler” interface. In the OnInputClicked(InputClickedEventData eventData) method we can perform actions when the user AirTap on the element. In the same way, if we implement the interface “IInputHandler” we can capture events “Click/Tap Down” and “Click/Tap Up” in an element of our app.

Note: Besides the AirTap action, this example serves to Click action on the Hololens clicker.

IMHO, I find it a much more ‘clean’ way this way of working with events using interfaces. Although there is still a way to go. In my next post, I will show how to work with hands and Hololens, for this sample the approach is not interface driven.

The sample code can be downloaded from GitHub (link)

Greetings @ Toronto

El Bruno



4 thoughts on “#Hololens – How to detect AirTap and Click actions using #HoloToolkit (updated!)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s