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.
GvrLaserPointer
Implementation of GvrBasePointer for a laser pointer visual.
Summary
This script should be attached to the controller object. The laser visual is important to help users locate their cursor when its not directly in their field of view.
Inheritance
Inherits from:
GvrBasePointer
Public functions
|
GetPointerRadius(out float enterRadius, out float exitRadius)
|
virtual override void
Return the radius of the pointer.
|
OnPointerClickDown()
|
virtual override void
Called when a click is initiated.
|
OnPointerClickUp()
|
virtual override void
Called when click is finished.
|
OnPointerEnter(RaycastResult raycastResult, bool isInteractive)
|
virtual override void
Called when the pointer is facing a valid GameObject.
|
OnPointerExit(GameObject previousObject)
|
virtual override void
Called when the pointer no longer faces an object previously intersected with a ray projected from the camera.
|
OnPointerHover(RaycastResult raycastResult, bool isInteractive)
|
virtual override void
Called every frame the user is still pointing at a valid GameObject.
|
Public attributes
defaultReticleDistance
float defaultReticleDistance = 20.0f
Distance from the pointer that the reticle will be drawn at when hitting nothing.
maxPointerDistance
float maxPointerDistance = 20.0f
Maximum distance from the pointer that raycast hits will be detected.
overrideCameraRayIntersectionDistance
float overrideCameraRayIntersectionDistance
By default, the length of the laser is used as the CameraRayIntersectionDistance.
Set this field to a non-zero value to override it.
Properties
CameraRayIntersectionDistance
override float CameraRayIntersectionDistance
LaserVisual
GvrLaserVisual LaserVisual
Gets the visual object for the laser beam.
The visual object for the laser beam.
MaxPointerDistance
override float MaxPointerDistance
Public functions
GetPointerRadius
virtual override void GetPointerRadius(
out float enterRadius,
out float exitRadius
)
Return the radius of the pointer.
OnPointerClickDown
virtual override void OnPointerClickDown()
Called when a click is initiated.
OnPointerClickUp
virtual override void OnPointerClickUp()
Called when click is finished.
OnPointerEnter
virtual override void OnPointerEnter(
RaycastResult raycastResult,
bool isInteractive
)
Called when the pointer is facing a valid GameObject.
OnPointerExit
virtual override void OnPointerExit(
GameObject previousObject
)
Called when the pointer no longer faces an object previously intersected with a ray projected from the camera.
OnPointerHover
virtual override void OnPointerHover(
RaycastResult raycastResult,
bool isInteractive
)
Called every frame the user is still pointing at a valid GameObject.
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\u003e\u003ccode\u003eGvrLaserPointer\u003c/code\u003e implements a laser pointer visual for VR controllers, extending the \u003ccode\u003eGvrBasePointer\u003c/code\u003e class.\u003c/p\u003e\n"],["\u003cp\u003eThe laser helps users locate the cursor when it's outside their direct field of view, improving user experience.\u003c/p\u003e\n"],["\u003cp\u003eIt provides properties to customize laser distance, reticle behavior, and visual representation using the \u003ccode\u003eGvrLaserVisual\u003c/code\u003e component.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can interact with pointer events like click, hover, and enter/exit using override functions like \u003ccode\u003eOnPointerClickDown\u003c/code\u003e, \u003ccode\u003eOnPointerHover\u003c/code\u003e, and \u003ccode\u003eOnPointerEnter\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe script should be attached to the controller object for proper functionality within the VR environment.\u003c/p\u003e\n"]]],["The GvrLaserPointer, attached to a controller object, implements a laser pointer visual to help users locate their cursor. Key actions include detecting raycast hits within a `maxPointerDistance` (default 20.0f) and drawing a reticle at a `defaultReticleDistance` (default 20.0f). The laser's length can be overridden. It manages pointer events like `OnPointerClickDown`, `OnPointerClickUp`, `OnPointerEnter`, `OnPointerExit`, and `OnPointerHover`, to interact with GameObjects, and the radius of the pointer can be changed.\n"],null,["# GvrLaserPointer Class Reference\n\nGvrLaserPointer\n===============\n\nImplementation of [GvrBasePointer](/vr/reference/unity/class/GvrBasePointer#classGvrBasePointer) for a laser pointer visual.\n\nSummary\n-------\n\nThis script should be attached to the controller object. The laser visual is important to help users locate their cursor when its not directly in their field of view.\n\n### Inheritance\n\nInherits from: [GvrBasePointer](/vr/reference/unity/class/GvrBasePointer)\n\n| ### Public attributes ||\n|---------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------|\n| [defaultReticleDistance](#classGvrLaserPointer_1ae6530796a9bc05e29666fd2195aaa980)` = 20.0f` | `float` Distance from the pointer that the reticle will be drawn at when hitting nothing. |\n| [maxPointerDistance](#classGvrLaserPointer_1a4eef42de2d9247f91d5a7f2ee6d65650)` = 20.0f` | `float` Maximum distance from the pointer that raycast hits will be detected. |\n| [overrideCameraRayIntersectionDistance](#classGvrLaserPointer_1aa2c589e6b0eadf38505096b22ec42050) | `float` By default, the length of the laser is used as the CameraRayIntersectionDistance. |\n\n| ### Properties ||\n|-------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------|\n| [CameraRayIntersectionDistance](#classGvrLaserPointer_1a92683fbe0809af15e27a7ab8b0e11f0e) | `override float` |\n| [LaserVisual](#classGvrLaserPointer_1a2a57f1e672c2032a51ee3d59c1d763ba) | [GvrLaserVisual](/vr/reference/unity/class/GvrLaserVisual#classGvrLaserVisual) Gets the visual object for the laser beam. |\n| [MaxPointerDistance](#classGvrLaserPointer_1a41ff424a067e3a46e73a1f5a4aca622e) | `override float` |\n\n| ### Public functions ||\n|-------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------|\n| [GetPointerRadius](#classGvrLaserPointer_1ae48930542cc1f6aab672dc395ab1eec7)`(out float enterRadius, out float exitRadius)` | `virtual override void` Return the radius of the pointer. |\n| [OnPointerClickDown](#classGvrLaserPointer_1a5f1b68216f5cece492cdde12c4e7bbc9)`()` | `virtual override void` Called when a click is initiated. |\n| [OnPointerClickUp](#classGvrLaserPointer_1a6d0ed35f5f7eb4f589cb03b473be7474)`()` | `virtual override void` Called when click is finished. |\n| [OnPointerEnter](#classGvrLaserPointer_1aa4ecb6ae7dd95992dc5637a826331c33)`(RaycastResult raycastResult, bool isInteractive)` | `virtual override void` Called when the pointer is facing a valid GameObject. |\n| [OnPointerExit](#classGvrLaserPointer_1a21a71a130e27eb96c991b0b59ffade4d)`(GameObject previousObject)` | `virtual override void` Called when the pointer no longer faces an object previously intersected with a ray projected from the camera. |\n| [OnPointerHover](#classGvrLaserPointer_1a78732710d8b8f6ff3c2a729fc0ffb4fd)`(RaycastResult raycastResult, bool isInteractive)` | `virtual override void` Called every frame the user is still pointing at a valid GameObject. |\n\nPublic attributes\n-----------------\n\n### defaultReticleDistance\n\n```c#\nfloat defaultReticleDistance = 20.0f\n``` \nDistance from the pointer that the reticle will be drawn at when hitting nothing. \n\n### maxPointerDistance\n\n```c#\nfloat maxPointerDistance = 20.0f\n``` \nMaximum distance from the pointer that raycast hits will be detected. \n\n### overrideCameraRayIntersectionDistance\n\n```c#\nfloat overrideCameraRayIntersectionDistance\n``` \nBy default, the length of the laser is used as the CameraRayIntersectionDistance.\n\nSet this field to a non-zero value to override it.\n\nProperties\n----------\n\n### CameraRayIntersectionDistance\n\n```c#\noverride float CameraRayIntersectionDistance\n``` \n\n### LaserVisual\n\n```c#\nGvrLaserVisual LaserVisual\n``` \nGets the visual object for the laser beam.\n\nThe visual object for the laser beam. \n\n### MaxPointerDistance\n\n```c#\noverride float MaxPointerDistance\n``` \n\nPublic functions\n----------------\n\n### GetPointerRadius\n\n```c#\nvirtual override void GetPointerRadius(\n out float enterRadius,\n out float exitRadius\n)\n``` \nReturn the radius of the pointer. \n\n### OnPointerClickDown\n\n```c#\nvirtual override void OnPointerClickDown()\n``` \nCalled when a click is initiated. \n\n### OnPointerClickUp\n\n```c#\nvirtual override void OnPointerClickUp()\n``` \nCalled when click is finished. \n\n### OnPointerEnter\n\n```c#\nvirtual override void OnPointerEnter(\n RaycastResult raycastResult,\n bool isInteractive\n)\n``` \nCalled when the pointer is facing a valid GameObject. \n\n### OnPointerExit\n\n```c#\nvirtual override void OnPointerExit(\n GameObject previousObject\n)\n``` \nCalled when the pointer no longer faces an object previously intersected with a ray projected from the camera. \n\n### OnPointerHover\n\n```c#\nvirtual override void OnPointerHover(\n RaycastResult raycastResult,\n bool isInteractive\n)\n``` \nCalled every frame the user is still pointing at a valid GameObject."]]