GvrPointerInputModule

This script provides an implemention of Unity's BaseInputModule class, so that Canvas-based (uGUI) UI elements and 3D scene objects can be interacted with in a Gvr Application.

Summary

This script is intended for use with either a 3D Pointer with the Daydream Controller (Recommended for Daydream), or a Gaze-based-Pointer (Recommended for Cardboard).

To use, attach to the scene's EventSystem object. Be sure to move it above the other modules, such as TouchInputModule and StandaloneInputModule, in order for the Pointer to take priority in the event system.

If you are using a Canvas, set the Render Mode to World Space, and add the GvrPointerGraphicRaycaster script to the object.

If you'd like pointers to work with 3D scene objects, add a GvrPointerPhysicsRaycaster to the main camera, and add a component that implements one of the Event interfaces (EventTrigger will work nicely) to an object with a collider.

GvrPointerInputModule emits the following events: Enter, Exit, Down, Up, Click, Select, Deselect, UpdateSelected, and GvrPointerHover. Scroll, move, and submit/cancel events are not emitted.

To use a 3D Pointer with the Daydream Controller:

  • Add the prefab GoogleVR/Prefabs/UI/GvrControllerPointer to your scene.
  • Set the parent of GvrControllerPointer to the same parent as the main camera (With a local position of 0,0,0).

To use a Gaze-based-pointer:

  • Add the prefab GoogleVR/Prefabs/UI/GvrReticlePointer to your scene.
  • Set the parent of GvrReticlePointer to the main camera.

Inheritance

Inherits from: BaseInputModule, IGvrInputModuleController

Public attributes

scrollInput = new GvrPointerScrollInput()
vrModeOnly = false
bool
Determines whether Pointer input is active in VR Mode only (true), or all of the time (false).

Properties

CurrentRaycastResult
static RaycastResult
Convenience function to access what the current RaycastResult.
EventExecutor
Impl
Pointer
RaycastResultCache
List< RaycastResult >
eventSystem
new EventSystem

Public static functions

FindEventExecutor()
Helper function to find the Event Executor that is part of the input module if one exists in the scene.
FindInputModule()
Helper function to find the input module if one exists in the scene and it is the active module.
OnPointerCreated(GvrBasePointer createdPointer)
void
GvrBasePointer calls this when it is created.

Public functions

Deactivate()
void
DeactivateModule()
override void
FindCommonRoot(GameObject g1, GameObject g2)
new GameObject
FindFirstRaycast(List< RaycastResult > candidates)
new RaycastResult
GetBaseEventData()
new BaseEventData
IsPointerOverGameObject(int pointerId)
override bool
Process()
override void
ShouldActivate()
bool
ShouldActivateModule()
override bool

Protected functions

Awake()
override void

Public attributes

scrollInput

GvrPointerScrollInput scrollInput = new GvrPointerScrollInput()

vrModeOnly

bool vrModeOnly = false

Determines whether Pointer input is active in VR Mode only (true), or all of the time (false).

Set to false if you plan to use direct screen taps or other input when not in VR Mode.

Properties

CurrentRaycastResult

static RaycastResult CurrentRaycastResult

Convenience function to access what the current RaycastResult.

EventExecutor

GvrEventExecutor EventExecutor

Impl

GvrPointerInputModuleImpl Impl

Pointer

static GvrBasePointer Pointer

RaycastResultCache

List< RaycastResult > RaycastResultCache

eventSystem

new EventSystem eventSystem

Public static functions

FindEventExecutor

GvrEventExecutor FindEventExecutor()

Helper function to find the Event Executor that is part of the input module if one exists in the scene.

FindInputModule

GvrPointerInputModule FindInputModule()

Helper function to find the input module if one exists in the scene and it is the active module.

OnPointerCreated

void OnPointerCreated(
  GvrBasePointer createdPointer
)

GvrBasePointer calls this when it is created.

If a pointer hasn't already been assigned, it will assign the newly created one by default.

This simplifies the common case of having only one GvrBasePointer so is can be automatically hooked up to the manager. If multiple GvrBasePointers are in the scene, the app has to take responsibility for setting which one is active.

Public functions

Deactivate

void Deactivate()

DeactivateModule

override void DeactivateModule()

FindCommonRoot

new GameObject FindCommonRoot(
  GameObject g1,
  GameObject g2
)

FindFirstRaycast

new RaycastResult FindFirstRaycast(
  List< RaycastResult > candidates
)

GetBaseEventData

new BaseEventData GetBaseEventData()

IsPointerOverGameObject

override bool IsPointerOverGameObject(
  int pointerId
)

Process

override void Process()

ShouldActivate

bool ShouldActivate()

ShouldActivateModule

override bool ShouldActivateModule()

Protected functions

Awake

override void Awake()