This site has been permanently archived. The content on this site was last updated in 2019.
Stay organized with collections
Save and categorize content based on your preferences.
GvrVRHelpers
Helper functions common to GVR VR applications.
Summary
Public static functions
GetHeadForward
Vector3 GetHeadForward()
Gets the forward vector relative to the headset's rotation.
Details |
Returns
|
The forward vector relative to the headset's rotation.
|
GetHeadPosition
Vector3 GetHeadPosition()
Gets the head's position.
Details |
Returns
|
The head's position.
|
GetHeadRotation
Quaternion GetHeadRotation()
Gets the headset's rotation.
Details |
Returns
|
The headset's rotation.
|
GetRayIntersection
float GetRayIntersection(
GvrBasePointer.RaycastMode mode
)
Gets the distance at which the Direct
and Camera
raycasts intersect.
This is the point at which Hybrid
mode will transition from Direct
(closer than the intersection) to Camera
(further than the intersection) mode.
Details |
Parameters |
mode
|
The RaycastMode for which to get the intersection distance. Only returns non-zero when this is RaycastMode.Camera .
|
|
Returns
|
The distance at which the Direct and Camera raycasts intersect.
|
GetRecommendedMaxLaserDistance
float GetRecommendedMaxLaserDistance(
GvrBasePointer.RaycastMode mode
)
Gets the recommended max laser distance, based on raycast mode.
Details |
Parameters |
mode
|
The RaycastMode for which to get the recommended distance.
|
|
Returns
|
The recommended maximum laser distance for the given mode.
|
GetShrinkLaser
bool GetShrinkLaser(
GvrBasePointer.RaycastMode mode
)
Returns a value indicating whether the laser is visually shrunken.
Details |
Parameters |
mode
|
The RaycastMode for which to check behavior.
|
|
Returns
|
Returns true if the laser is shrunken, false a otherwise.
|
GetViewportCenter
Vector2 GetViewportCenter()
Gets the center of the screen or eye texture, in pixels.
Details |
Returns
|
The center of the screen, in pixels.
|
All rights reserved. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-10-09 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-10-09 UTC."],[[["\u003cp\u003eGvrVRHelpers provides helper functions for Google VR applications in Unity.\u003c/p\u003e\n"],["\u003cp\u003eThese functions help retrieve head position, rotation, and forward vector, useful for VR interactions.\u003c/p\u003e\n"],["\u003cp\u003eIt also offers functionalities related to raycasting and laser pointers, including intersection distances and recommended laser lengths.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can utilize GvrVRHelpers to simplify common VR tasks and enhance user experiences.\u003c/p\u003e\n"]]],["GvrVRHelpers offers functions for VR applications. Key actions include retrieving the headset's: forward vector (`GetHeadForward`), position (`GetHeadPosition`), and rotation (`GetHeadRotation`). Additional functions determine raycast intersection distances (`GetRayIntersection`), recommended maximum laser distances (`GetRecommendedMaxLaserDistance`), and whether the laser is visually shrunken (`GetShrinkLaser`). It also retrieves the center of the screen or eye texture in pixels (`GetViewportCenter`). Each function relies on specific parameters or returns values relevant to VR rendering and user interaction.\n"],null,["# GvrVRHelpers Class Reference\n\nGvrVRHelpers\n============\n\nHelper functions common to GVR VR applications.\n\nSummary\n-------\n\n| ### Public static functions ||\n|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------|\n| [GetHeadForward](#classGvrVRHelpers_1a5126c2a351451048ab88920f9f632e0d)`()` | `Vector3` Gets the forward vector relative to the headset's rotation. |\n| [GetHeadPosition](#classGvrVRHelpers_1af469f8ef23bfb0ee07c95e032aa48228)`()` | `Vector3` Gets the head's position. |\n| [GetHeadRotation](#classGvrVRHelpers_1a85a23144335c954b449eddc5979cf4bb)`()` | `Quaternion` Gets the headset's rotation. |\n| [GetRayIntersection](#classGvrVRHelpers_1ae1acb62d405023b575700be2c143ba03)`(`[GvrBasePointer.RaycastMode](/vr/reference/unity/class/GvrBasePointer#classGvrBasePointer_1a8de79b1db10e6f55fe6738a4358b73fe)` mode)` | `float` Gets the distance at which the `Direct` and `Camera` raycasts intersect. |\n| [GetRecommendedMaxLaserDistance](#classGvrVRHelpers_1a1233d60e6e6f19bdf5a410a59cdb0332)`(`[GvrBasePointer.RaycastMode](/vr/reference/unity/class/GvrBasePointer#classGvrBasePointer_1a8de79b1db10e6f55fe6738a4358b73fe)` mode)` | `float` Gets the recommended max laser distance, based on raycast mode. |\n| [GetShrinkLaser](#classGvrVRHelpers_1a55e67b97109f440e0e24c87262840eea)`(`[GvrBasePointer.RaycastMode](/vr/reference/unity/class/GvrBasePointer#classGvrBasePointer_1a8de79b1db10e6f55fe6738a4358b73fe)` mode)` | `bool` Returns a value indicating whether the laser is visually shrunken. |\n| [GetViewportCenter](#classGvrVRHelpers_1aa9b3cb23757be3c2330b90e5a5ae2c8b)`()` | `Vector2` Gets the center of the screen or eye texture, in pixels. |\n\nPublic static functions\n-----------------------\n\n### GetHeadForward\n\n```c#\nVector3 GetHeadForward()\n``` \nGets the forward vector relative to the headset's rotation.\n\n\u003cbr /\u003e\n\n| Details ||\n|-------------|--------------------------------------------------------|\n| **Returns** | The forward vector relative to the headset's rotation. |\n\n### GetHeadPosition\n\n```c#\nVector3 GetHeadPosition()\n``` \nGets the head's position.\n\n\u003cbr /\u003e\n\n| Details ||\n|-------------|----------------------|\n| **Returns** | The head's position. |\n\n### GetHeadRotation\n\n```c#\nQuaternion GetHeadRotation()\n``` \nGets the headset's rotation.\n\n\u003cbr /\u003e\n\n| Details ||\n|-------------|-------------------------|\n| **Returns** | The headset's rotation. |\n\n### GetRayIntersection\n\n```c#\nfloat GetRayIntersection(\n GvrBasePointer.RaycastMode mode\n)\n``` \nGets the distance at which the `Direct` and `Camera` raycasts intersect.\n\nThis is the point at which `Hybrid` mode will transition from `Direct` (closer than the intersection) to `Camera` (further than the intersection) mode.\n\n\u003cbr /\u003e\n\n| Details ||\n|-------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Parameters | |--------|------------------------------------------------------------------------------------------------------------------------| | `mode` | The `RaycastMode` for which to get the intersection distance. Only returns non-zero when this is `RaycastMode.Camera`. | |\n| **Returns** | The distance at which the `Direct` and `Camera` raycasts intersect. |\n\n### GetRecommendedMaxLaserDistance\n\n```c#\nfloat GetRecommendedMaxLaserDistance(\n GvrBasePointer.RaycastMode mode\n)\n``` \nGets the recommended max laser distance, based on raycast mode.\n\n\u003cbr /\u003e\n\n| Details ||\n|-------------|-----------------------------------------------------------------------------------------------------------------------------------------------------|\n| Parameters | |--------|--------------------------------------------------------------| | `mode` | The `RaycastMode` for which to get the recommended distance. | |\n| **Returns** | The recommended maximum laser distance for the given mode. |\n\n### GetShrinkLaser\n\n```c#\nbool GetShrinkLaser(\n GvrBasePointer.RaycastMode mode\n)\n``` \nReturns a value indicating whether the laser is visually shrunken.\n\n\u003cbr /\u003e\n\n| Details ||\n|-------------|-------------------------------------------------------------------------------------------------------------------------|\n| Parameters | |--------|------------------------------------------------| | `mode` | The `RaycastMode` for which to check behavior. | |\n| **Returns** | Returns `true` if the laser is shrunken, `false`a otherwise. |\n\n### GetViewportCenter\n\n```c#\nVector2 GetViewportCenter()\n``` \nGets the center of the screen or eye texture, in pixels.\n\n\u003cbr /\u003e\n\n| Details ||\n|-------------|--------------------------------------|\n| **Returns** | The center of the screen, in pixels. |"]]