WaveVR_Raycast¶
Contents |
Introduction¶
The script WaveVR_Raycast.cs is used to cast a ray from an object like below photo:
This script has the following features:
- Creating a LineRenderer: you can see a ray being shown on the screen.
- Casting an invisible ray: this feature can be used to detect a 3D or 2D GameObject in world space.
How to use¶
Add the component WaveVR_Raycast to the object you want to add a ray to:
In editor mode, you can play a scene to see the effect.
Use “right alt + mouse” to controll the rotation.
Script¶
You can see public variables:
Device Index
: The index of the connected device. It is to use with next variable -Listen To Device
.Listen To Device
: If checked, the LineRenderer is only generated when a controller with the specifiedDevice Index
is connected. Otherwise the LineRenderer is always created.Add LineRenderer
: If unchecked, the LineRender will never be created. This can be unchecked if you do NOT want to use LineRenderer. (e.g. use Mesh)
When a device is connected or disconnected, OnDeviceConnected
will enable / disable the LineRenderer.
private void OnDeviceConnected(params object[] args)
{
var device = (WVR_DeviceType)args[0];
var connected = (bool)args[1];
if (index != device) // check if the role of connected device is equivalent to developer specified index.
return;
if (lr != null)
{
lr.enabled = connected;
}
}