Hello!
During the last few months HoloToolkit has changed a lot. These changes make some of the examples that I have written as non-valid posts. In today’s post, I’ll quickly explain how to implement detection of hands with the current version of HoloToolkit.
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 existing scripts
- 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
- AnchorText (from HoloToolkit)
- Position, x:0 y:0.35 z:2
- Rotation, x:0 y:0 z:0
- Scale, x:0.3 y:0.3 z:0.3
- Cube
- Add 3D elements
- Into the Manager collection
- Add script Text Debug Manager (later on the post)
- Drag the Anchor Text (7.1.2) into the Anchor Debug Text Property
- Add script Text Debug Manager (later on the post)
This is the process creating a basic Hololens project. Now let’s create a script that detects any of the user actions with his hands. This script will display these actions in the AnchorText which I have added to the collection of holograms in debug mode.
For this example, I will call the script “TextDebugManager.cs“. The same code is as follows
using HoloToolkit.Unity.InputModule;
using UnityEngine;
public class TextDebugManager : MonoBehaviour, IHoldHandler, IInputHandler
{
public TextMesh AnchorDebugText;
private string _debugTextHold = "";
private string _debugTextInput = "";
void Update()
{
UpdateText();
}
private void UpdateText()
{
if (AnchorDebugText != null)
AnchorDebugText.text = string.Format(
"Hold: {0}\nInput: {1}", _debugTextHold, _debugTextInput);
}
public void OnHoldStarted(HoldEventData eventData)
{
_debugTextHold = "OnHoldStarted";
}
public void OnHoldCompleted(HoldEventData eventData)
{
_debugTextHold = "OnHoldCompleted";
}
public void OnHoldCanceled(HoldEventData eventData)
{
_debugTextHold = "OnHoldCanceled";
}
public void OnInputUp(InputEventData eventData)
{
_debugTextInput = "OnInputUp";
}
public void OnInputDown(InputEventData eventData)
{
_debugTextInput = "OnInputDown";
}
}
Within the class I implemented interfaces “IHoldHandle” and “IInputHandler“. Then be shown the operations be interfaces in the Update() of the script. In this way, we can implement a model of Debug PPP of Hololens in a quick way, and in this case, to capture the interactions of the user about the holograms.
Greetings @ TorontoEl Bruno
References
- GitHub, HoloToolkit
- GitHub, HoloToolkit Unity
- El Bruno, How to Import the HoloToolkit Unity
- El Bruno, How to place a Hologram using AirTap and HoloToolkit
- El Bruno, Creating a menu with options with HoloToolkit
- El Bruno, Using voice commands to display a menu with HoloToolkit
- El Bruno, How to create a 3D text always visible using HoloToolkit
- El Bruno, How to create a HUD (3D text always visible without HoloToolkit)
- El Bruno, How to detect hands using HoloToolkit
- El Bruno, Windows 10, Xbox One Controller, Bluetooth and some lessons learned
- El Bruno, How to use Fire Buttons actions with an XBoxOne Controller
- El Bruno, Moving and rotating holograms using an XBoxOne Controller
- El Bruno, How to detect AirTap and Click actions using HoloToolkit (updated!)
Leave a reply to #Hololens – Getting Started with #MixedRealityToolkit #MRToolkit – El Bruno Cancel reply