GvrLaserVisual

Visualizes a laser and a reticle using a LineRenderer and a Quad.

Summary

Provides functions for settings the end point of the laser, and clamps the laser and reticle based on max distances.

Inheritance

Inherits from: MonoBehaviour, IGvrArmModelReceiver

Public attributes

beginShrinkAngleDegrees = 0.0f
float
Begin shrinking the laser when the angle between transform.forward and the reticle is greater than this value.
controller
Transform
The end point of the visual will not necessarily be along the forward direction of the laser.
endShrinkAngleDegrees = 2.0f
float
Finish shrinking the laser when the angle between transform.forward and the reticle is greater than this value.
laserColor = new Color(1.0f, 1.0f, 1.0f, 0.25f)
Color
Color of the laser pointer including alpha transparency.
laserColorEnd = new Color(1.0f, 1.0f, 1.0f, 0.0f)
Color
Color of the laser pointer including alpha transparency.
lerpSpeed = 20.0f
float
The rate that the current position moves towards the target position.
lerpThreshold = 1.0f
float
If the targetPosition is greater than this threshold, then the position changes immediately instead of lerping.
maxLaserDistance = 1.0f
float
Maximum distance of the laser (meters).
reticle
Used to position the reticle at the current position.
shrinkLaser = true
bool
This is primarily used for Hybrid Raycast mode (details in GvrBasePointer ) to prevent mismatches between the laser and the reticle when the "camera" component of the ray is used.
shrunkScale = 0.2f
float
Amount to shrink the laser when it is fully shrunk.

Properties

ArmModel
CurrentDistance
float
GetPointForDistanceFunction
Laser
LineRenderer
Reference to the laser's line renderer.

Protected attributes

currentDistance
float
currentLocalPosition
Vector3
currentLocalRotation
Quaternion
currentPosition
Vector3
shrinkRatio
float
targetDistance
float

Public functions

GetPointForDistanceDelegate(float distance)
delegate Vector3
Optional delegate for customizing how the currentPosition is calculated based on the distance.
SetDistance(float distance, bool immediate)
virtual void
Set the distance of the laser.

Protected functions

Awake()
virtual void
GetSpeed()
virtual float
LateUpdate()
virtual void
UpdateControllerOrientation()
virtual void
UpdateCurrentPosition()
virtual void
UpdateLaserAlpha()
virtual void
UpdateLaserEndPoint()
virtual void
UpdateReticlePosition()
virtual void

Public attributes

beginShrinkAngleDegrees

float beginShrinkAngleDegrees = 0.0f

Begin shrinking the laser when the angle between transform.forward and the reticle is greater than this value.

controller

Transform controller

The end point of the visual will not necessarily be along the forward direction of the laser.

This is particularly true in both Camera and Hybrid Raycast Modes. In that case, both the laser and the controller are rotated to face the end point. This reference is used to control the rotation of the controller.

endShrinkAngleDegrees

float endShrinkAngleDegrees = 2.0f

Finish shrinking the laser when the angle between transform.forward and the reticle is greater than this value.

laserColor

Color laserColor = new Color(1.0f, 1.0f, 1.0f, 0.25f)

Color of the laser pointer including alpha transparency.

laserColorEnd

Color laserColorEnd = new Color(1.0f, 1.0f, 1.0f, 0.0f)

Color of the laser pointer including alpha transparency.

lerpSpeed

float lerpSpeed = 20.0f

The rate that the current position moves towards the target position.

lerpThreshold

float lerpThreshold = 1.0f

If the targetPosition is greater than this threshold, then the position changes immediately instead of lerping.

maxLaserDistance

float maxLaserDistance = 1.0f

Maximum distance of the laser (meters).

reticle

GvrControllerReticleVisual reticle

Used to position the reticle at the current position.

shrinkLaser

bool shrinkLaser = true

This is primarily used for Hybrid Raycast mode (details in GvrBasePointer ) to prevent mismatches between the laser and the reticle when the "camera" component of the ray is used.

shrunkScale

float shrunkScale = 0.2f

Amount to shrink the laser when it is fully shrunk.

Properties

ArmModel

GvrBaseArmModel ArmModel

CurrentDistance

float CurrentDistance

GetPointForDistanceFunction

GetPointForDistanceDelegate GetPointForDistanceFunction

Laser

LineRenderer Laser

Reference to the laser's line renderer.

Protected attributes

currentDistance

float currentDistance

currentLocalPosition

Vector3 currentLocalPosition

currentLocalRotation

Quaternion currentLocalRotation

currentPosition

Vector3 currentPosition

shrinkRatio

float shrinkRatio

targetDistance

float targetDistance

Public functions

GetPointForDistanceDelegate

delegate Vector3 GetPointForDistanceDelegate(
  float distance
)

Optional delegate for customizing how the currentPosition is calculated based on the distance.

If not set, the currentPosition is determined based on the distance multiplied by the forward direction of the transform added to the position of the transform.

SetDistance

virtual void SetDistance(
  float distance,
  bool immediate
)

Set the distance of the laser.

Clamps the distance of the laser and reticle.

distance target distance from the pointer to draw the visual at. immediate If true, the distance is changed immediately. Otherwise, it will lerp.

Protected functions

Awake

virtual void Awake()

GetSpeed

virtual float GetSpeed()

LateUpdate

virtual void LateUpdate()

UpdateControllerOrientation

virtual void UpdateControllerOrientation()

UpdateCurrentPosition

virtual void UpdateCurrentPosition()

UpdateLaserAlpha

virtual void UpdateLaserAlpha()

UpdateLaserEndPoint

virtual void UpdateLaserEndPoint()

UpdateReticlePosition

virtual void UpdateReticlePosition()