Class GestureTransformationUtility
Provides helper functions for common functionality to transform objects in AR.
Inherited Members
Namespace: UnityEngine.XR.Interaction.Toolkit.AR
Syntax
public static class GestureTransformationUtility
Methods
GetBestPlacementPosition(Vector3, Vector2, Single, Single, Single, GestureTransformationUtility.GestureTranslationMode)
Calculates the best position to place an object in AR based on screen position. Could be used for tapping a location on the screen, dragging an object, or using a fixed cursor in the center of the screen for placing and moving objects.
Declaration
[Obsolete("GetBestPlacementPosition has been deprecated. Use GetBestPlacementPosition with updated signature instead.")]
public static GestureTransformationUtility.Placement GetBestPlacementPosition(Vector3 currentAnchorPosition, Vector2 screenPos, float groundingPlaneHeight, float hoverOffset, float maxTranslationDistance, GestureTransformationUtility.GestureTranslationMode gestureTranslationMode)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | currentAnchorPosition | Position of the parent anchor, i.e., where the object is before translation starts. |
Vector2 | screenPos | Location on the screen in pixels to place the object at. |
Single | groundingPlaneHeight | The starting height of the plane to place the object on. |
Single | hoverOffset | How much should the object hover above the groundingPlane before it has been placed. |
Single | maxTranslationDistance | The maximum distance allowed to translate the object. |
GestureTransformationUtility.GestureTranslationMode | gestureTranslationMode | The translation mode, indicating the plane types allowed. |
Returns
Type | Description |
---|---|
GestureTransformationUtility.Placement | Returns the best placement position. |
Remarks
Unity places objects along the x/z of the grounding plane. When placed on an AR plane below the grounding plane, the object will drop straight down onto it in world space. This prevents the object from being pushed deeper into the scene when moving from a higher plane to a lower plane. When moving from a lower plane to a higher plane, this function returns a new groundingPlane to replace the old one.
GetBestPlacementPosition(Vector3, Vector2, Single, Single, Single, GestureTransformationUtility.GestureTranslationMode, ARSessionOrigin, TrackableType, Int32)
Calculates the best position to place an object in AR based on screen position. Could be used for tapping a location on the screen, dragging an object, or using a fixed cursor in the center of the screen for placing and moving objects.
Declaration
[Obsolete("GetBestPlacementPosition with the ARSessionOrigin parameter has been deprecated. Use GetBestPlacementPosition with the XROrigin parameter instead.")]
public static GestureTransformationUtility.Placement GetBestPlacementPosition(Vector3 currentAnchorPosition, Vector2 screenPosition, float groundingPlaneHeight, float hoverOffset, float maxTranslationDistance, GestureTransformationUtility.GestureTranslationMode gestureTranslationMode, ARSessionOrigin sessionOrigin, TrackableType trackableTypes = null, int fallbackLayerMask = 0)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | currentAnchorPosition | Position of the parent anchor, i.e., where the object is before translation starts. |
Vector2 | screenPosition | Location on the screen in pixels to place the object at. |
Single | groundingPlaneHeight | The starting height of the plane to place the object on. |
Single | hoverOffset | How much should the object hover above the groundingPlane before it has been placed. |
Single | maxTranslationDistance | The maximum distance allowed to translate the object. |
GestureTransformationUtility.GestureTranslationMode | gestureTranslationMode | The translation mode, indicating the plane types allowed. |
ARSessionOrigin | sessionOrigin | The |
TrackableType | trackableTypes | (Optional) The types of trackables to cast against. |
Int32 | fallbackLayerMask | (Optional) The LayerMask that Unity uses during an additional ray cast when no trackables are hit. Defaults to Nothing which skips the fallback ray cast. |
Returns
Type | Description |
---|---|
GestureTransformationUtility.Placement | Returns the best placement position. |
Remarks
Unity places objects along the x/z of the grounding plane. When placed on an AR plane below the grounding plane, the object will drop straight down onto it in world space. This prevents the object from being pushed deeper into the scene when moving from a higher plane to a lower plane. When moving from a lower plane to a higher plane, this function returns a new groundingPlane to replace the old one.
GetBestPlacementPosition(Vector3, Vector2, Single, Single, Single, GestureTransformationUtility.GestureTranslationMode, XROrigin, TrackableType, Int32)
Calculates the best position to place an object in AR based on screen position. Could be used for tapping a location on the screen, dragging an object, or using a fixed cursor in the center of the screen for placing and moving objects.
Declaration
public static GestureTransformationUtility.Placement GetBestPlacementPosition(Vector3 currentAnchorPosition, Vector2 screenPosition, float groundingPlaneHeight, float hoverOffset, float maxTranslationDistance, GestureTransformationUtility.GestureTranslationMode gestureTranslationMode, XROrigin sessionOrigin, TrackableType trackableTypes = null, int fallbackLayerMask = 0)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | currentAnchorPosition | Position of the parent anchor, i.e., where the object is before translation starts. |
Vector2 | screenPosition | Location on the screen in pixels to place the object at. |
Single | groundingPlaneHeight | The starting height of the plane to place the object on. |
Single | hoverOffset | How much should the object hover above the groundingPlane before it has been placed. |
Single | maxTranslationDistance | The maximum distance allowed to translate the object. |
GestureTransformationUtility.GestureTranslationMode | gestureTranslationMode | The translation mode, indicating the plane types allowed. |
XROrigin | sessionOrigin | The XROrigin used for ray casting. |
TrackableType | trackableTypes | (Optional) The types of trackables to cast against. |
Int32 | fallbackLayerMask | (Optional) The LayerMask that Unity uses during an additional ray cast when no trackables are hit. Defaults to Nothing which skips the fallback ray cast. |
Returns
Type | Description |
---|---|
GestureTransformationUtility.Placement | Returns the best placement position. |
Remarks
Unity places objects along the x/z of the grounding plane. When placed on an AR plane below the grounding plane, the object will drop straight down onto it in world space. This prevents the object from being pushed deeper into the scene when moving from a higher plane to a lower plane. When moving from a lower plane to a higher plane, this function returns a new groundingPlane to replace the old one.
Raycast(Vector2, List<ARRaycastHit>, ARSessionOrigin, TrackableType, Int32)
Cast a ray from a point in screen space against trackables, i.e., detected features such as planes. Can optionally fallback to hit test against Colliders in the loaded Scenes when no trackables were hit.
Declaration
[Obsolete("Raycast with the ARSessionOrigin parameter has been deprecated. Use Raycast with the XROrigin parameter instead.")]
public static bool Raycast(Vector2 screenPoint, List<ARRaycastHit> hitResults, ARSessionOrigin sessionOrigin, TrackableType trackableTypes = null, int fallbackLayerMask = 0)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | screenPoint | The point, in device screen pixels, from which to cast. |
List<ARRaycastHit> | hitResults | Contents are replaced with the ray cast results, if successful. |
ARSessionOrigin | sessionOrigin | The |
TrackableType | trackableTypes | (Optional) The types of trackables to cast against. |
Int32 | fallbackLayerMask | (Optional) The LayerMask that Unity uses during an additional ray cast when no trackables are hit. Defaults to Nothing which skips the fallback ray cast. |
Returns
Type | Description |
---|---|
Boolean | Returns true if the ray cast hit a trackable in the |
Raycast(Vector2, List<ARRaycastHit>, TrackableType)
Cast a ray from a point in screen space against trackables, i.e., detected features such as planes.
Declaration
[Obsolete("Raycast has been deprecated. Use Raycast with updated signature instead.")]
public static bool Raycast(Vector2 screenPoint, List<ARRaycastHit> hitResults, TrackableType trackableTypes = null)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | screenPoint | The point, in device screen pixels, from which to cast. |
List<ARRaycastHit> | hitResults | Contents are replaced with the ray cast results, if successful. |
TrackableType | trackableTypes | (Optional) The types of trackables to cast against. |
Returns
Type | Description |
---|---|
Boolean | Returns true if the ray cast hit a trackable in the |
Raycast(Vector2, List<ARRaycastHit>, XROrigin, TrackableType, Int32)
Cast a ray from a point in screen space against trackables, i.e., detected features such as planes. Can optionally fallback to hit test against Colliders in the loaded Scenes when no trackables were hit.
Declaration
public static bool Raycast(Vector2 screenPoint, List<ARRaycastHit> hitResults, XROrigin sessionOrigin, TrackableType trackableTypes = null, int fallbackLayerMask = 0)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | screenPoint | The point, in device screen pixels, from which to cast. |
List<ARRaycastHit> | hitResults | Contents are replaced with the ray cast results, if successful. |
XROrigin | sessionOrigin | The XROrigin used for ray casting. |
TrackableType | trackableTypes | (Optional) The types of trackables to cast against. |
Int32 | fallbackLayerMask | (Optional) The LayerMask that Unity uses during an additional ray cast when no trackables are hit. Defaults to Nothing which skips the fallback ray cast. |
Returns
Type | Description |
---|---|
Boolean | Returns true if the ray cast hit a trackable in the |