docs.unity3d.com
    Show / Hide Table of Contents

    Class GestureTransformationUtility

    Provides helper functions for common functionality for transforming objects in AR.

    Inheritance
    Object
    GestureTransformationUtility
    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 used for raycasting.

    TrackableType trackableTypes

    (Optional) The types of trackables to cast against.

    Int32 fallbackLayerMask

    (Optional) The that is used during an additional raycast when no trackables are hit. Defaults to Nothing which skips the fallback raycast.

    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 used for raycasting.

    TrackableType trackableTypes

    (Optional) The types of trackables to cast against.

    Int32 fallbackLayerMask

    (Optional) The that is used during an additional raycast when no trackables are hit. Defaults to Nothing which skips the fallback raycast.

    Returns
    Type Description
    Boolean

    Returns true if the raycast hit a trackable in the trackableTypes or if the fallback raycast hit. Otherwise, returns false.

    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 trackableTypes. Otherwise, returns false.

    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023