# GvrPointerInputModule Class Reference

# GvrPointerInputModule

This script provides an implemention of Unity's `BaseInputModule` class.

## Summary

Exists so that Canvas-based (`uGUI`) UI elements and 3D scene objects can be interacted with in a Gvr Application.

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 `https://developers.google.com/vr/reference/unity/class/GvrPointerGraphicRaycaster#classGvrPointerGraphicRaycaster` script to the object.

If you'd like pointers to work with 3D scene objects, add a `https://developers.google.com/vr/reference/unity/class/GvrPointerPhysicsRaycaster#classGvrPointerPhysicsRaycaster` 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.

`https://developers.google.com/vr/reference/unity/class/GvrPointerInputModule#classGvrPointerInputModule` 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).

<br />

To use a Gaze-based-pointer:

- Add the prefab GoogleVR/Prefabs/UI/GvrReticlePointer to your scene.
- Set the parent of `https://developers.google.com/vr/reference/unity/class/GvrReticlePointer#classGvrReticlePointer` to the main camera.

<br />

### Inheritance

Inherits from: BaseInputModule, [IGvrInputModuleController](https://developers.google.com/vr/reference/unity/interface/IGvrInputModuleController)

| ### Public attributes ||
|---|---|
| `https://developers.google.com/vr/reference/unity/class/GvrPointerInputModule#classGvrPointerInputModule_1a085b4a1585aebf74e9094b9ea3b5ef3d = new GvrPointerScrollInput()` | `https://developers.google.com/vr/reference/unity/class/GvrPointerScrollInput#classGvrPointerScrollInput` Manages scroll events for the input module. |
| `https://developers.google.com/vr/reference/unity/class/GvrPointerInputModule#classGvrPointerInputModule_1a73776e4022479c6cf40f8616ed513144 = false` | `bool` If `true`, pointer input is active in VR Mode only. |

| ### Properties ||
|---|---|
| `https://developers.google.com/vr/reference/unity/class/GvrPointerInputModule#classGvrPointerInputModule_1aaf4d96ab1c78bfcd5fa43063300c1f08` | `static RaycastResult` Gets the current `RaycastResult`. |
| `https://developers.google.com/vr/reference/unity/class/GvrPointerInputModule#classGvrPointerInputModule_1a2132868310219a276b3e7dc63b5e628d` | `https://developers.google.com/vr/reference/unity/class/GvrEventExecutor#classGvrEventExecutor` Gets the executor this module uses to process events. |
| `https://developers.google.com/vr/reference/unity/class/GvrPointerInputModule#classGvrPointerInputModule_1a76758b2e2124de91b10449e46dd3b88c` | `https://developers.google.com/vr/reference/unity/class/GvrPointerInputModuleImpl#classGvrPointerInputModuleImpl` Gets the implementation object of this module. |
| `https://developers.google.com/vr/reference/unity/class/GvrPointerInputModule#classGvrPointerInputModule_1a05b8be4770e9707ca2841f36a52f2278` | `static https://developers.google.com/vr/reference/unity/class/GvrBasePointer#classGvrBasePointer` Gets or sets the static reference to the `https://developers.google.com/vr/reference/unity/class/GvrBasePointer#classGvrBasePointer`. |
| `https://developers.google.com/vr/reference/unity/class/GvrPointerInputModule#classGvrPointerInputModule_1a95ebfd9a963e534b34cfc48eb78c2a4e` | `List< RaycastResult >` Gets the list of raycast results used as a cache. |
| `https://developers.google.com/vr/reference/unity/class/GvrPointerInputModule#classGvrPointerInputModule_1a0cdc761949da676c997f1f9f1a2913c5` | `new EventSystem` Gets the event system reference. |

| ### Public static functions ||
|---|---|
| `https://developers.google.com/vr/reference/unity/class/GvrPointerInputModule#classGvrPointerInputModule_1a018e38125d0f9e2c766ae33af1b8771a()` | `https://developers.google.com/vr/reference/unity/class/GvrEventExecutor#classGvrEventExecutor` Helper function to find the Event executor that is part of the input module if one exists in the scene. |
| `https://developers.google.com/vr/reference/unity/class/GvrPointerInputModule#classGvrPointerInputModule_1af3af943a06b292c8bc62c643fe33a620()` | `https://developers.google.com/vr/reference/unity/class/GvrPointerInputModule#classGvrPointerInputModule` Helper function to find the input module if one exists in the scene and it is the active module. |
| `https://developers.google.com/vr/reference/unity/class/GvrPointerInputModule#classGvrPointerInputModule_1ac50c1204f9c97c7a2b81264c9f2632f3(https://developers.google.com/vr/reference/unity/class/GvrBasePointer#classGvrBasePointer createdPointer)` | `void` The `https://developers.google.com/vr/reference/unity/class/GvrBasePointer#classGvrBasePointer` calls this when it is created. |

| ### Public functions ||
|---|---|
| `https://developers.google.com/vr/reference/unity/class/GvrPointerInputModule#classGvrPointerInputModule_1ab5b44e4fafa11a9b25e591c371b06b09()` | `void` Deactivate this instance. |
| `https://developers.google.com/vr/reference/unity/class/GvrPointerInputModule#classGvrPointerInputModule_1ad0e49ae6addf05a7c944016a1078811c()` | `override void` |
| `https://developers.google.com/vr/reference/unity/class/GvrPointerInputModule#classGvrPointerInputModule_1ade1ec9c66c5a8b4786785561a2a221fd(GameObject g1, GameObject g2)` | `new GameObject` Finds the common root between two `GameObject`s. |
| `https://developers.google.com/vr/reference/unity/class/GvrPointerInputModule#classGvrPointerInputModule_1a06c0e88440d8d972db4c3f250f417de2(List< RaycastResult > candidates)` | `new RaycastResult` Finds the first raycast. |
| `https://developers.google.com/vr/reference/unity/class/GvrPointerInputModule#classGvrPointerInputModule_1a170dbac4b97f4c6cf3b2ee039dee20ea()` | `new BaseEventData` Gets the base event data. |
| `https://developers.google.com/vr/reference/unity/class/GvrPointerInputModule#classGvrPointerInputModule_1adfa23ceb87d2b99f29ef24e36b24de82(int pointerId)` | `override bool` |
| `https://developers.google.com/vr/reference/unity/class/GvrPointerInputModule#classGvrPointerInputModule_1a3dcecb1c62dae252bee720e64eb3e03b()` | `override void` |
| `https://developers.google.com/vr/reference/unity/class/GvrPointerInputModule#classGvrPointerInputModule_1af933d6cb9b218ff98fb51dca25de4afb()` | `bool` Whether the module should be activated. |
| `https://developers.google.com/vr/reference/unity/class/GvrPointerInputModule#classGvrPointerInputModule_1a5efc6b9c2074a7a474444223a8d6b5ea()` | `override bool` |

## Public attributes

### scrollInput

```c#
GvrPointerScrollInput scrollInput = new GvrPointerScrollInput()
```
Manages scroll events for the input module.

### vrModeOnly

```c#
bool vrModeOnly = false
```
If `true`, pointer input is active in VR Mode only.

If `false`, pointer input is active all of the time.

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

## Properties

### CurrentRaycastResult

```c#
static RaycastResult CurrentRaycastResult
```
Gets the current `RaycastResult`.

The current `RaycastResult`.

### EventExecutor

```c#
GvrEventExecutor EventExecutor
```
Gets the executor this module uses to process events.

The executor this module uses to process events.

### Impl

```c#
GvrPointerInputModuleImpl Impl
```
Gets the implementation object of this module.

The implementation object of this module.

### Pointer

```c#
static GvrBasePointer Pointer
```
Gets or sets the static reference to the `https://developers.google.com/vr/reference/unity/class/GvrBasePointer#classGvrBasePointer`.

The static reference to the `https://developers.google.com/vr/reference/unity/class/GvrBasePointer#classGvrBasePointer`.

### RaycastResultCache

```c#
List< RaycastResult > RaycastResultCache
```
Gets the list of raycast results used as a cache.

The list of raycast results used as a cache.

### eventSystem

```c#
new EventSystem eventSystem
```
Gets the event system reference.

The event system reference.

## Public static functions

### FindEventExecutor

```c#
GvrEventExecutor FindEventExecutor()
```
Helper function to find the Event executor that is part of the input module if one exists in the scene.

<br />

| Details ||
|---|---|
| **Returns** | A found [GvrEventExecutor](https://developers.google.com/vr/reference/unity/class/GvrEventExecutor#classGvrEventExecutor) or null. |

### FindInputModule

```c#
GvrPointerInputModule FindInputModule()
```
Helper function to find the input module if one exists in the scene and it is the active module.

<br />

| Details ||
|---|---|
| **Returns** | A found `https://developers.google.com/vr/reference/unity/class/GvrPointerInputModule#classGvrPointerInputModule` or null. |

### OnPointerCreated

```c#
void OnPointerCreated(
  GvrBasePointer createdPointer
)
```
The `https://developers.google.com/vr/reference/unity/class/GvrBasePointer#classGvrBasePointer` 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 `https://developers.google.com/vr/reference/unity/class/GvrBasePointer#classGvrBasePointer` so it 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.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `createdPointer` | The pointer whose creation triggered this call. | |

## Public functions

### Deactivate

```c#
void Deactivate()
```
Deactivate this instance.

### DeactivateModule

```c#
override void DeactivateModule()
```

### FindCommonRoot

```c#
new GameObject FindCommonRoot(
  GameObject g1,
  GameObject g2
)
```
Finds the common root between two `GameObject`s.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `g1` | The first `GameObject`. | | `g2` | The second `GameObject`. | |
| **Returns** | The common root. |

### FindFirstRaycast

```c#
new RaycastResult FindFirstRaycast(
  List< RaycastResult > candidates
)
```
Finds the first raycast.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `candidates` | The list of `RaycastResult`s to search for the first Raycast. | |
| **Returns** | The first raycast. |

### GetBaseEventData

```c#
new BaseEventData GetBaseEventData()
```
Gets the base event data.

<br />

| Details ||
|---|---|
| **Returns** | The base event data. |

### IsPointerOverGameObject

```c#
override bool IsPointerOverGameObject(
  int pointerId
)
```

### Process

```c#
override void Process()
```

### ShouldActivate

```c#
bool ShouldActivate()
```
Whether the module should be activated.

<br />

| Details ||
|---|---|
| **Returns** | Returns `true` if this module should be activated, `false` otherwise. |

### ShouldActivateModule

```c#
override bool ShouldActivateModule()
```