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

EnvironmentRaycastManager Class

Extends MonoBehaviour
Please note: EnvironmentRaycastManager is currently in BETA.
You can ship your app to the store with it, but its API may change in future versions of MRUK.
This component uses Depth API to provide raycasting functionality against the physical environment.
Enabling this component adds the additional performance cost to the cost of using Depth API, so consider enabling it only when you need the raycasting functionality.
This component automatically adds and enables the EnvironmentDepthManager. Consider disabling the EnvironmentDepthManager manually after disabling the EnvironmentRaycastManager to save performance.

Properties

Checks if the environment raycast is supported.
bool IsReady[Get]

Member Functions

Casts a ray against the environment.
Returns 'true' if the cast is successful.
Parameters
ray
The starting point and direction of the ray.
hit
The result of the raycast.
maxDistance
The max distance the ray should check for collisions.
Returns
'true' if EnvironmentRaycastHit.status is EnvironmentRaycastHitStatus.Hit.
Tries to place the box on the flat and free surface.

First, this method aligns the box with the flat surface: box.forward is aligned with the surface normal, box.up is aligned with upwards .
Then it checks if the box can fit the environment by checking collisions.
Parameters
ray
The desired direction of placement. The common use case is to construct this ray with:
new Ray(controllerTransform.position, controllerTransform.forward)
boxSize
Size of the box in local-space coordinates. Width is aligned with the local x-axis, height is aligned with the local y-axis, length is aligned with the local z-axis.
'x' and 'y' components should be greater than EnvironmentDepthManagerRaycastExtensions.MinXYSize to correctly determine the surface normal.
'z' component can be zero for flat objects.
upwards
The local y-axis of the box is aligned with upwards vector before checking for collisions with the environment.
hit
Contains the placement result. Example of how to apply the pose to the object:
transform.SetPositionAndRotation(hit.point, Quaternion.LookRotation(hit.normal, upwards));
Returns
'true' only if the surface is flat, free of clutter and big enough to fit the dimensions of the box.
Checks whether the given box overlaps with the environment.
Parameters
center
Center of the box.
halfExtents
Half the size of the box in each dimension.
orientation
Rotation of the box.
Returns
Returns 'true' if the box overlaps with the environment.
Did you find this page helpful?
Thumbs up icon
Thumbs down icon