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

OVRExtensions Class

Miscellaneous extension methods that any script can use.
This class encapulsates several extension methods that help convert between the Quest's coordinate system and Unity's coorindate system. Use these methods to convert to and from the Quest's local tracking space and Unity's world space, for example.
This class also contains several methods to facilitate native interop, as the native plugin uses a different coordinate system than Unity (for example, OVRPlugin.Posef). These methods are used by the Meta XR Core SDK, but typically should not necessary in application code.

Static Methods

ConvertToHMDMatrix34 ( m )
Converts a matrix between the native plugin and Unity format.
This method is used to convert a matrix between the native OVR.OpenVR.HmdMatrix34_t format and a UnityEngine Matrix4x4.
This method negates the Z axis of the rotation and translation, which converts between the native right-handed coordinate system and Unity's left-handed coordinate system.
This method is for advanced usage and is not typically used by application code.
Signature
static OVR.OpenVR.HmdMatrix34_t ConvertToHMDMatrix34(this Matrix4x4 m)
Parameters
m: this Matrix4x4  The Matrix4x4 to convert.
Returns
OVR.OpenVR.HmdMatrix34_t  Returns m as an OVR.OpenVR.HmdMatrix34_t.
CopyFrom ( gradient , otherGradient )
Copies one gradiant into another.
Signature
static void CopyFrom(this Gradient gradient, Gradient otherGradient)
Parameters
gradient: this Gradient  The Gradient that otherGradient will be copied into.
otherGradient: Gradient  The Gradient to copy into gradient .
Returns
void
Equals ( gradient , otherGradient )
Compares two Gradients for equality.
Signature
static bool Equals(this Gradient gradient, Gradient otherGradient)
Parameters
gradient: this Gradient  The Gradient to compare with otherGradient.
otherGradient: Gradient  The Gradient to compare with gradient.
Returns
bool  Returns true if gradient is equal to otherGradient .
FindChildRecursive ( parent , name )
Recursively searches for a child transform with the given name.
Note that only children of parent are considered. parent itself is not included in the search.
A child transform is considered a match if any part of its name contains name .
Signature
static Transform FindChildRecursive(this Transform parent, string name)
Parameters
parent: this Transform  The transform at which to begin the search.
name: string  The name of the transform to find.
Returns
Transform  Returns the first child of parent with name , or null, if no such child exists.
FromColorf ( c )
Converts a OVRPlugin.Colorf to a UnityEngine Color.
This method is used to convert color data between the native OVRPlugin.Colorf format and a UnityEngine Color.
This method is for advanced usage and is not typically used by application code.
Signature
static Color FromColorf(this OVRPlugin.Colorf c)
Parameters
c: this OVRPlugin.Colorf  A color in native color format.
Returns
Color c as a UnityEngine Color.
FromFlippedXQuatf ( q )
Converts a quaternion between the native plugin and Unity format.
This method is used to convert a quaternion between the native OVRPlugin.Quatf format and a UnityEngine Quaternion.
This method negates the Y and Z components of the quaternion, which has the effect of flipping the rotation about the X axis.
This method is for advanced usage and is not typically used by application code.
Signature
static Quaternion FromFlippedXQuatf(this OVRPlugin.Quatf q)
Parameters
q: this OVRPlugin.Quatf  A quaternion as an OVRPlugin.Quatf.
Returns
Quaternion q as a UnityEngine Quaternion.
FromFlippedXVector2f ( v )
Converts a OVRPlugin.Vector2f to a UnityEngine Vector2.
This method is used to convert vector data between the native OVRPlugin.Vector2f format and a UnityEngine Vector2.
This method negates the X component of the OVRPlugin.Vector2f.
This method is for advanced usage and is not typically used by application code.
Signature
static Vector2 FromFlippedXVector2f(this OVRPlugin.Vector2f v)
Parameters
v: this OVRPlugin.Vector2f  A vector in OVRPlugin's native format.
Returns
Vector2 v as a UnityEngine Vector2.
FromFlippedXVector3f ( v )
Converts a 3d vector between the native plugin and Unity format.
This method is used to convert a 3d vector between the native OVRPlugin.Vector3f format and a UnityEngine Vector3.
This method negates the X component of v .
This method is for advanced usage and is not typically used by application code.
Signature
static Vector3 FromFlippedXVector3f(this OVRPlugin.Vector3f v)
Parameters
v: this OVRPlugin.Vector3f  A 3d vector as an OVRPlugin.Vector3f.
Returns
Vector3 v as a UnityEngine Vector3.
FromFlippedZQuatf ( q )
Converts a quaternion between the native plugin and Unity format.
This method is used to convert a quaternion between the native OVRPlugin.Quatf format and a UnityEngine Quaternion.
This method negates the X and Y components of the quaternion, which has the effect of flipping the rotation about the Z axis.
This method is for advanced usage and is not typically used by application code.
Signature
static Quaternion FromFlippedZQuatf(this OVRPlugin.Quatf q)
Parameters
q: this OVRPlugin.Quatf  A quaternion as an OVRPlugin.Quatf.
Returns
Quaternion q as a UnityEngine Quaternion.
FromFlippedZVector3f ( v )
Converts a 3d vector between the native plugin and Unity format.
This method is used to convert a 3d vector between the native OVRPlugin.Vector3f format and a UnityEngine Vector3.
This method negates the Z component of v .
This method is for advanced usage and is not typically used by application code.
Signature
static Vector3 FromFlippedZVector3f(this OVRPlugin.Vector3f v)
Parameters
v: this OVRPlugin.Vector3f  A 3d vector as an OVRPlugin.Vector3f.
Returns
Vector3 v as a UnityEngine Vector3.
FromOVRPose ( t , pose , isLocal )
Sets a transform to the given OVRPose.
Signature
static void FromOVRPose(this Transform t, OVRPose pose, bool isLocal=false)
Parameters
t: this Transform  The transform whose position and rotation will be set.
pose: OVRPose  The OVRPose to convert to t .
isLocal: bool  If true, t 's local position and transform are set. Otherwise, sets the world position and rotation.
Returns
void
FromQuatf ( q )
Converts a quaternion between the native plugin and Unity format.
This method is used to convert a quaternion between the native OVRPlugin.Quatf format and a UnityEngine Quaternion.
This method is for advanced usage and is not typically used by application code.
Signature
static Quaternion FromQuatf(this OVRPlugin.Quatf q)
Parameters
q: this OVRPlugin.Quatf  A quaternion as an OVRPlugin.Quatf.
Returns
Quaternion q as a UnityEngine Quaternion.
FromSize3f ( v )
Converts size information between the native plugin and Unity format.
This method is used to convert size data between the native OVRPlugin.Size3f format and a UnityEngine Vector3.
This method is for advanced usage and is not typically used by application code.
Signature
static Vector3 FromSize3f(this OVRPlugin.Size3f v)
Parameters
v: this OVRPlugin.Size3f  A size as a OVRPlugin.Size3f.
Returns
Vector3 v as a UnityEngine Vector3.
FromSizef ( v )
Converts a OVRPlugin.Sizef to a UnityEngine Vector2.
This method is used to convert size data between the native OVRPlugin.Sizef format and a UnityEngine Vector2.
This method is for advanced usage and is not typically used by application code.
Signature
static Vector2 FromSizef(this OVRPlugin.Sizef v)
Parameters
v: this OVRPlugin.Sizef  A size in OVRPlugin's native format.
Returns
Vector2 v as a UnityEngine Vector2.
FromVector2f ( v )
Converts a OVRPlugin.Vector2f to a UnityEngine Vector2.
This method is used to convert vector data between the native OVRPlugin.Vector2f format and a UnityEngine Vector2.
This method is for advanced usage and is not typically used by application code.
Signature
static Vector2 FromVector2f(this OVRPlugin.Vector2f v)
Parameters
v: this OVRPlugin.Vector2f  A vector in OVRPlugin's native format.
Returns
Vector2 v as a UnityEngine Vector2.
FromVector3f ( v )
Converts a 3d vector between the native plugin and Unity format.
This method is used to convert a 3d vector between the native OVRPlugin.Vector3f format and a UnityEngine Vector3.
This method is for advanced usage and is not typically used by application code.
Signature
static Vector3 FromVector3f(this OVRPlugin.Vector3f v)
Parameters
v: this OVRPlugin.Vector3f  A 3d vector as an OVRPlugin.Vector3f.
Returns
Vector3 v as a UnityEngine Vector3.
FromVector4f ( v )
Converts a 4d vector between the native plugin and Unity format.
This method is used to convert a 4d vector between the native OVRPlugin.Vector4f format and a UnityEngine Vector4.
This method is for advanced usage and is not typically used by application code.
Signature
static Vector4 FromVector4f(this OVRPlugin.Vector4f v)
Parameters
v: this OVRPlugin.Vector4f  A 4d vector as an OVRPlugin.Vector4f.
Returns
Vector4 v as a UnityEngine Vector4.
IsQRCode ( value )
Determines whether a OVRMarkerPayloadType refers to a QR Code.
Signature
static bool IsQRCode(this OVRMarkerPayloadType value)
Parameters
value: this OVRMarkerPayloadType  The OVRMarkerPayloadType to test.
Returns
bool  Returns true if value is a QR Code; otherwise, false.
ToColorf ( c )
Converts a UnityEngine Color to a OVRPlugin.Colorf.
This method is used to convert color data between the native OVRPlugin.Colorf format and a UnityEngine Color.
This method is for advanced usage and is not typically used by application code.
Signature
static OVRPlugin.Colorf ToColorf(this Color c)
Parameters
c: this Color  A color in Unity's Color format.
Returns
OVRPlugin.Colorf c as a OVRPlugin.Colorf.
ToFlippedXQuatf ( q )
Converts a quaternion between the native plugin and Unity format.
This method is used to convert a quaternion between the native OVRPlugin.Quatf format and a UnityEngine Quaternion.
This method negates the Y and Z components of the quaternion, which has the effect of flipping the rotation about the X axis.
This method is for advanced usage and is not typically used by application code.
Signature
static OVRPlugin.Quatf ToFlippedXQuatf(this Quaternion q)
Parameters
q: this Quaternion  A quaternion as a UnityEngine Quaternion.
Returns
OVRPlugin.Quatf q as an OVRPlugin.Quatf.
ToFlippedXVector3f ( v )
Converts a 3d vector between the native plugin and Unity format.
This method is used to convert a 3d vector between the native OVRPlugin.Vector3f format and a UnityEngine Vector3.
This method negates the X component of v .
This method is for advanced usage and is not typically used by application code.
Signature
static OVRPlugin.Vector3f ToFlippedXVector3f(this Vector3 v)
Parameters
v: this Vector3  A 3d vector as UnityEngine Vector3.
Returns
OVRPlugin.Vector3f v as an OVRPlugin.Vector3f.
ToFlippedZQuatf ( q )
Converts a quaternion between the native plugin and Unity format.
This method is used to convert a quaternion between the native OVRPlugin.Quatf format and a UnityEngine Quaternion.
This method negates the X and Y components of the quaternion, which has the effect of flipping the rotation about the Z axis.
This method is for advanced usage and is not typically used by application code.
Signature
static OVRPlugin.Quatf ToFlippedZQuatf(this Quaternion q)
Parameters
q: this Quaternion  A quaternion as a UnityEngine Quaternion.
Returns
OVRPlugin.Quatf q as an OVRPlugin.Quatf.
ToFlippedZVector3f ( v )
Converts a 3d vector between the native plugin and Unity format.
This method is used to convert a 3d vector between the native OVRPlugin.Vector3f format and a UnityEngine Vector3.
This method negates the Z component of v .
This method is for advanced usage and is not typically used by application code.
Signature
static OVRPlugin.Vector3f ToFlippedZVector3f(this Vector3 v)
Parameters
v: this Vector3  A 3d vector as UnityEngine Vector3.
Returns
OVRPlugin.Vector3f v as an OVRPlugin.Vector3f.
ToFrustum ( f )
Converts an OVRPlugin.Frustumf to an OVRTracker.Frustum.
OVRPlugin.Frustumf is typically used for native interop with native plugins. This method converts that native format into a format that is more compatible with Unity.
This method is for advanced usage.
Signature
static OVRTracker.Frustum ToFrustum(this OVRPlugin.Frustumf f)
Parameters
f: this OVRPlugin.Frustumf  The OVRPlugin.Frustumf to convert to OVRTracker.Frustum.
Returns
OVRTracker.Frustum f converted to an OVRTracker.Frustum.
ToHeadSpacePose ( trackingSpacePose )
Converts the given pose from tracking-space to head-space.
The "tracking space" refers to the local coordinate system of the Quest device. This method converts a pose in tracking space to a pose relative to the XRNode.Head.
Signature
static OVRPose ToHeadSpacePose(this OVRPose trackingSpacePose)
Parameters
trackingSpacePose: this OVRPose  The pose, in tracking space, that should be converted to head space.
Returns
OVRPose trackingSpacePose in head space.
ToHeadSpacePose ( transform , camera )
Converts the given world-space transform to an OVRPose in head space.
The "head space" refers to the local coordinate system of the Quest HMD. This method converts the given transform to an equivalent pose relative to the user's head.
Signature
static OVRPose ToHeadSpacePose(this Transform transform, Camera camera)
Parameters
transform: this Transform  The transform to convert to head space.
camera: Camera  The camera whose transform is driven by the Quest HMD. This is often the main camera.
Returns
OVRPose transform converted to a head relative pose.
ToOVRPose ( t , isLocal )
Converts the given transform to an OVRPose.
Signature
static OVRPose ToOVRPose(this Transform t, bool isLocal=false)
Parameters
t: this Transform  The transform to convert to a pose.
isLocal: bool  If true, uses the local position and transform of t . Otherwise, uses the world space position and rotation.
Returns
OVRPose t as a OVRPose.
ToOVRPose ( p )
Converts an OVRPlugin.Posef to an OVRPose.
OVRPlugin.Posef is typically used for native interop with native plugins, and uses a different coordinate system (right-handed as opposed to Unity's left-handed coordinate system).
This method converts the right-handed OVRPlugin.Posef to a left-handed OVRPose compatible with Unity's coordinate system.
This method is for advanced usage.
Signature
static OVRPose ToOVRPose(this OVRPlugin.Posef p)
Parameters
p: this OVRPlugin.Posef  A right-handed pose acquired from a native function call.
Returns
OVRPose p converted to an OVRPose.
ToQuatf ( q )
Converts a quaternion between the native plugin and Unity format.
This method is used to convert a quaternion between the native OVRPlugin.Quatf format and a UnityEngine Quaternion.
This method is for advanced usage and is not typically used by application code.
Signature
static OVRPlugin.Quatf ToQuatf(this Quaternion q)
Parameters
q: this Quaternion  A quaternion as a UnityEngine Quaternion.
Returns
OVRPlugin.Quatf q as an OVRPlugin.Quatf.
ToSize3f ( v )
Converts size information between the native plugin and Unity format.
This method is used to convert size data between the native OVRPlugin.Size3f format and a UnityEngine Vector3.
This method is for advanced usage and is not typically used by application code.
Signature
static OVRPlugin.Size3f ToSize3f(this Vector3 v)
Parameters
v: this Vector3  A size as a UnityEngine Vector3.
Returns
OVRPlugin.Size3f v as a OVRPlugin.Size3f.
ToSizef ( v )
Converts a Vector2 to a OVRPlugin.Sizef.
This method is used to convert size data between the native OVRPlugin.Sizef format and a UnityEngine Vector2.
This method is for advanced usage and is not typically used by application code.
Signature
static OVRPlugin.Sizef ToSizef(this Vector2 v)
Parameters
v: this Vector2  A size as a Vector2.
Returns
OVRPlugin.Sizef v as an OVRPlugin compatible OVRPlugin.Sizef.
ToTrackingSpacePose ( transform , camera )
Converts the given world-space transform to an OVRPose in tracking space.
The "tracking space" refers to the local coordinate system of the Quest device. This method uses a camera's world-space transform to calculate the transform between the Quest's tracking space and Unity's world space, then applies it to the transform to compute that transform in the device's tracking space.
Signature
static OVRPose ToTrackingSpacePose(this Transform transform, Camera camera)
Parameters
transform: this Transform  A transform that will be converted to a tracking space pose.
camera: Camera  The camera whose transform is driven by the HMD. This is often the main camera.
Returns
OVRPose  Returns the pose of the transform in tracking space.
ToVector2f ( v )
Converts a Vector2 to a OVRPlugin.Vector2f.
This method is used to convert vector data between the native OVRPlugin.Vector2f format and a UnityEngine Vector2.
This method is for advanced usage and is not typically used by application code.
Signature
static OVRPlugin.Vector2f ToVector2f(this Vector2 v)
Parameters
v: this Vector2  A UnityEngine Vector2.
Returns
OVRPlugin.Vector2f v as a OVRPlugin.Vector2f.
ToVector3f ( v )
Converts a 3d vector between the native plugin and Unity format.
This method is used to convert a 3d vector between the native OVRPlugin.Vector3f format and a UnityEngine Vector3.
This method is for advanced usage and is not typically used by application code.
Signature
static OVRPlugin.Vector3f ToVector3f(this Vector3 v)
Parameters
v: this Vector3  A 3d vector as UnityEngine Vector3.
Returns
OVRPlugin.Vector3f v as an OVRPlugin.Vector3f.
ToVector4f ( v )
Converts a 4d vector between the native plugin and Unity format.
This method is used to convert a 4d vector between the native OVRPlugin.Vector4f format and a UnityEngine Vector4.
This method is for advanced usage and is not typically used by application code.
Signature
static OVRPlugin.Vector4f ToVector4f(this Vector4 v)
Parameters
v: this Vector4  A 4d vector as UnityEngine Vector4.
Returns
OVRPlugin.Vector4f v as an OVRPlugin.Vector4f.
ToWorldSpacePose ( trackingSpacePose )
Converts the given pose from tracking-space to world-space.
DeprecatedThis method is obsolete. Use ToWorldSpacePose(OVRPose, Camera) instead.
The "tracking space" refers to the local coordinate system of the Quest device. This method uses the main camera's world-space transform to calculate the transform between the Quest's tracking space and Unity's world space, then applies it to the trackingSpacePose to compute that pose in Unity world space.
Signature
static OVRPose ToWorldSpacePose(this OVRPose trackingSpacePose)
Parameters
trackingSpacePose: this OVRPose  The pose, in tracking-space, to convert to world space.
Returns
OVRPose  The trackingSpacePose in world space.
ToWorldSpacePose ( trackingSpacePose , mainCamera )
Converts the given pose from tracking-space to world-space.
The "tracking space" refers to the local coordinate system of the Quest device. This method uses mainCamera 's world-space transform to calculate the transform between the Quest's tracking space and Unity's world space, then applies it to the trackingSpacePose to compute that pose in Unity world space.
This is the inverse operation of ToTrackingSpacePose.
Signature
static OVRPose ToWorldSpacePose(this OVRPose trackingSpacePose, Camera mainCamera)
Parameters
trackingSpacePose: this OVRPose  The pose to convert to world-space.
mainCamera: Camera  The camera whose transform is driven by the HMD. This is often the main camera.
Returns
OVRPose trackingSpacePose in world space.