API reference
API reference
Select your platform
No SDKs available
No versions available

RayInteractable Class

Defines a raycast interaction suitable to use at both short and long ranges.
The possibility of interaction is triggered by the intersection between the RayInteractor's raycast and the interactable's Surface. Consequences of interaction can be controlled by setting the interactable's movement provider (through the UnityEditor or via InjectOptionalMovementProvider(IMovementProvider)), by observing the interactable's IInteractable events (for example, using an InteractableUnityEventWrapper), or by handling the PointerEvents emitted during interaction (for example, by forwarding them to an IPointableCanvas).

Properties

Surface : ISurface
[Get]
The mesh used as the interactive surface for the ray.
This value of this property is typically set in the UnityEditor, but it can also be set programmatically using InjectSurface(ISurface).
Signature
ISurface Oculus.Interaction.RayInteractable.Surface
TiebreakerScore : int
[Get][Set]
If a RayInteractor's raycast strikes multiple interactables such that it is equally interactable with any of them, the interactable with the largest TiebreakerScore wins and is targeted for interaction.
If there's a tie for largest TiebreakerScore, one of the interactables will be selected arbitrarily.
Signature
int Oculus.Interaction.RayInteractable.TiebreakerScore

Protected Methods

Awake ()
Signature
override void Oculus.Interaction.RayInteractable.Awake()
Returns
override void
Start ()
Signature
override void Oculus.Interaction.RayInteractable.Start()
Returns
override void

Methods

GenerateMovement ( to , source )
Generates movement to move the <cref="RayInteractable" /> from its current position to the target position.
Signature
IMovement Oculus.Interaction.RayInteractable.GenerateMovement(in Pose to, in Pose source)
Parameters
to: in Pose  The target position.
source: in Pose  The current position.
Returns
IMovement  Returns the movement that will be applied to the interactable.
InjectAllRayInteractable ( surface )
Injects all required dependencies for a dynamically instantiated RayInteractable; because only Surface is required, this simply wraps InjectSurface(ISurface).
This method exists to support Interaction SDK's dependency injection pattern and is not needed for typical Unity Editor-based usage.
Signature
void Oculus.Interaction.RayInteractable.InjectAllRayInteractable(ISurface surface)
Parameters
surface: ISurface
Returns
void
InjectOptionalMovementProvider ( provider )
Sets an IMovementProvider for a dynamically instantiated RayInteractable.
This method exists to support Interaction SDK's dependency injection pattern and is not needed for typical Unity Editor-based usage.
Signature
void Oculus.Interaction.RayInteractable.InjectOptionalMovementProvider(IMovementProvider provider)
Parameters
Returns
void
InjectOptionalSelectSurface ( surface )
Sets an ISurface as the select surface for a dynamically instantiated RayInteractable.
This method exists to support Interaction SDK's dependency injection pattern and is not needed for typical Unity Editor-based usage.
Signature
void Oculus.Interaction.RayInteractable.InjectOptionalSelectSurface(ISurface surface)
Parameters
surface: ISurface
Returns
void
InjectSurface ( surface )
Sets an ISurface as the Surface for a dynamically instantiated RayInteractable.
This method exists to support Interaction SDK's dependency injection pattern and is not needed for typical Unity Editor-based usage.
Signature
void Oculus.Interaction.RayInteractable.InjectSurface(ISurface surface)
Parameters
surface: ISurface
Returns
void
Raycast ( ray , hit , maxDistance , selectSurface )
Called when the interactor has a set of interactables and is calculating which one is closest.
Signature
bool Oculus.Interaction.RayInteractable.Raycast(Ray ray, out SurfaceHit hit, in float maxDistance, bool selectSurface)
Parameters
ray: Ray  The position and direction of the ray.
hit: out SurfaceHit  The location, normal, and distance of the ray hit.
maxDistance: in float  The maximum ray length.
selectSurface: bool  True if the raycast has hit the selectable part of the <cref="RayInteractable" />, otherwise false.
Returns
bool  Returns true if hit.