WaveVR_Raycast¶
Contents |
Introduction¶
This script WaveVR_Raycast.cs is used to shot a ray from object looks like:
This script has features:
- Create a LineRenderer: developer can see a ray being shown on screen.
- Cast a invisible ray: can be used to detect 3D or 2D GameObject in world space.
How to use¶
Just add component WaveVR_Raycast to object you want to add ray like:
In editor mode, developer can play scene to see the effect.
Use “right alt” and mouse to controll the rotation.
Script¶
Developer can see four public variables:
- Device Index: index of connected device. It is for use with next variable - Listen To Device.
- Listen To Device: if checked, the LineRenderer is only generated when controller with specified Device Index is connected. Otherwise the LineRenderer is always created.
- Add LineRenderer: if unchecked, the LineRender will never be created. This can be unchecked if developer does NOT wanna use LineRenderer. (eq. use Mesh)
When 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;
}
}