Skip to content
Erwan Normand edited this page Oct 21, 2017 · 15 revisions

An input module provides support for a particular input device, using device-specific data to control the cursors in a scene.

Overview

Location

All input modules are contained within the /Assets/Hover/InputModules/ folder.

Installation

There are three main steps for installing an input module in your project:

  1. Install the device-related SDK(s).
  2. Use "multi-scene editing" to load the input module's scene.
  3. Set the input module's "Scripting Define Symbol".

Input Device SDKs

An input module will not work until you install the SDK(s) required for the input device.

Input modules typically depend on assets from a third-party SDK (for example, the "Leap Motion" input module uses a prefab, components, and the API from the Leap Motion SDK). These SDKs are not included within a Hover UI Kit release (or within its source repository).

Multiple Scenes

Each input module includes a scene that contains everything needed to use that particular input device. These scenes follow the naming convention "HoverInputModule-X", where "X" is the input module name.

To use an input module, drag the module's scene from the Unity "Project" window into the "Hierarchy" window (learn about Multi-Scene Editing). In many cases (especially for VR-related modules) the module's scene will contain cameras, so cameras in the main scene can be disabled.

Input module scenes can be loaded into your scene automatically. To enable this, attach the HoverSceneLoader component to any object in your main scene. You'll need to replace the "NAME" placeholders in the string properties to match the input module name (like "LeapMotion" or "Vive"). When this script is present, the target input module scene is loaded whenever your open your main scene in the Unity editor, and whenever your scene starts executing (which is useful for creating app builds). You can also use the component's "Reload Scene" button to manually trigger the loading process.

Note: an alternative approach would have been to create a single prefab for each input module. However, this would break any device-specific prefab references (for example, Leap Motion's "head-mounted rig" prefab). The scene-based approach maintains those prefab references, which should make it easier to upgrade to new device SDKs.

Define Symbols

An input module will not work until its "Scripting Define Symbol" has been defined. Each module scene includes a disabled GameObject (with a name starting with "NOTE:") that provides the symbol name. Symbol names follow the naming convention "HOVER_INPUT_X", where "X" is the input module name (all capital letters).

To set the symbol in Unity, go to Player settings > Other Settings > Scipting Define Symbols, add the symbol name, and hit Enter to confirm it (learn more).

All device-specific input module code is contained within #if HOVER_INPUT_X preprocessor directives. That code is not included in compilation until the symbol is defined. This allows code from multiple input modules to be present even when your project does not include the relevant input device SDK.

Scene Copies

It is possible to copy or rebuild the contents of an input module scene, then place those contents directly into your scene. This avoids the use of Unity's multi-scene editing feature. However, note that the contents of an input module scene may change over time, and referencing the scene itself (rather than copying its contents) will ensure the content stays up-to-date.

Modules

Name/Link Description
None Allows cursors to be controlled via their own transforms.
Follow Allows cursors to be controlled via external transforms.
LeapMotion Converts fingertips and palms into cursors (Orion/v3+).
LeapMotionOld Converts fingertips and palms into cursors (v2).
Vive Converts various positions on the Vive controllers into cursors.
OculusTouch Converts various positions on the Oculus Touch controllers into cursors.