Class GestureTransformationUtility
Provides helper functions for common functionality for transforming objects in AR.
Namespace: UnityEngine.XR.Interaction.Toolkit.AR
Syntax
public static class GestureTransformationUtility : object
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
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 that the object is being placed along. |
Single | hoverOffset | How much should the object hover above the groundingPlane before it has been placed. |
Single | maxTranslationDistance | The maximum distance that the object can be translated. |
GestureTransformationUtility.GestureTranslationMode | gestureTranslationMode | The translation mode, indicating the plane types allowed. |
Returns
Type | Description |
---|---|
GestureTransformationUtility.Placement | Returns the best placement position. |
Remarks
Objects are placed 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
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 that the object is being placed along. |
Single | hoverOffset | How much should the object hover above the groundingPlane before it has been placed. |
Single | maxTranslationDistance | The maximum distance that the object can be translated. |
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 |
Returns
Type | Description |
---|---|
GestureTransformationUtility.Placement | Returns the best placement position. |
Remarks
Objects are placed 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
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 raycast results, if successful. |
ARSessionOrigin | sessionOrigin | The |
TrackableType | trackableTypes | (Optional) The types of trackables to cast against. |
Int32 | fallbackLayerMask | (Optional) The |
Returns
Type | Description |
---|---|
Boolean | Returns true if the raycast 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
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 raycast results, if successful. |
TrackableType | trackableTypes | (Optional) The types of trackables to cast against. |
Returns
Type | Description |
---|---|
Boolean | Returns true if the raycast hit a trackable in the |