API reference

EnvironmentRaycastManager Class

Extends MonoBehaviour
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.

Fields

CustomTrackingSpace : Transform
This transform allows you to override the default tracking space.
Signature
Transform CustomTrackingSpace

Properties

IsSupported : bool
[Get]
Checks if the environment raycast is supported.
Signature
bool IsSupported

Methods

CheckBox ( center , halfExtents , orientation )
Checks whether the given box overlaps with the environment.
Signature
bool CheckBox(Vector3 center, Vector3 halfExtents, Quaternion orientation)
Parameters
center: Vector3  Center of the box.
halfExtents: Vector3  Half the size of the box in each dimension.
orientation: Quaternion  Rotation of the box.
Returns
bool  Returns 'true' if the box overlaps with the environment.
PlaceBox ( ray , boxSize , upwards , 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.
Signature
bool PlaceBox(Ray ray, Vector3 boxSize, Vector3 upwards, out EnvironmentRaycastHit hit)
Parameters
ray: Ray  The desired direction of placement. The common use case is to construct this ray with:
new Ray(controllerTransform.position, controllerTransform.forward)
boxSize: Vector3  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: Vector3  The local y-axis of the box is aligned with upwards vector before checking for collisions with the environment.
hit: out EnvironmentRaycastHit  Contains the placement result. Example of how to apply the pose to the object:
transform.SetPositionAndRotation(hit.point, Quaternion.LookRotation(hit.normal, upwards));
Returns
bool  'true' only if the surface is flat, free of clutter and big enough to fit the dimensions of the box.
Raycast ( ray , hit , maxDistance )
Casts a ray against the environment.
Returns 'true' if the cast is successful.
Signature
bool Raycast(Ray ray, out EnvironmentRaycastHit hit, float maxDistance=100f)
Parameters
ray: Ray  The starting point and direction of the ray.
hit: out EnvironmentRaycastHit  The result of the raycast.
maxDistance: float  The max distance the ray should check for collisions.
Returns
bool  'true' if EnvironmentRaycastHit.status is EnvironmentRaycastHitStatus.Hit.