docs.unity3d.com
    Show / Hide Table of Contents

    Class XRInteractableUtility

    Utility methods for Interactables.

    Inheritance
    Object
    XRInteractableUtility
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: UnityEngine.XR.Interaction.Toolkit.Utilities
    Syntax
    public static class XRInteractableUtility

    Methods

    TryGetClosestCollider(IXRInteractable, Vector3, out DistanceInfo)

    Calculates the closest Interactable's Collider to the given location (based on the Collider Transform position). The Collider volume and surface are not considered for calculation, use TryGetClosestPointOnCollider(IXRInteractable, Vector3, out DistanceInfo) in this case.

    Declaration
    public static bool TryGetClosestCollider(IXRInteractable interactable, Vector3 position, out DistanceInfo distanceInfo)
    Parameters
    Type Name Description
    IXRInteractable interactable

    Interactable to find the closest Collider position.

    Vector3 position

    Location in world space to calculate the closest Collider position.

    DistanceInfo distanceInfo

    If true is returned, distanceInfo will contain the closest Collider, its position (in world space) and its distance squared to the given location.

    Returns
    Type Description
    Boolean

    Returns true if the closest Collider can be computed, for this the interactable must have at least one active and enabled Collider. Otherwise, returns false.

    Remarks

    Only active and enabled Colliders are used in the calculation.

    See Also
    DistanceInfo
    TryGetClosestPointOnCollider(IXRInteractable, Vector3, out DistanceInfo)

    TryGetClosestPointOnCollider(IXRInteractable, Vector3, out DistanceInfo)

    Calculates the point on the Interactable's Colliders that is closest to the given location (based on the Collider volume and surface).

    Declaration
    public static bool TryGetClosestPointOnCollider(IXRInteractable interactable, Vector3 position, out DistanceInfo distanceInfo)
    Parameters
    Type Name Description
    IXRInteractable interactable

    Interactable to find the closest point.

    Vector3 position

    Location in world space to calculate the closest point.

    DistanceInfo distanceInfo

    If true is returned, distanceInfo will contain the point (in world space) on the Collider that is closest to the given location, its distance squared, and the Collider that contains the point. If the given location is in the Collider, the closest point will be inside. Otherwise, the closest point will be on the surface of the Collider.

    Returns
    Type Description
    Boolean

    Returns true if the closest point can be computed, for this the interactable must have at least one active and enabled Collider. Otherwise, returns false.

    Remarks

    Only active and enabled Colliders are used in the calculation. The Colliders can only be BoxColliders, SphereColliders, CapsuleColliders or convex MeshColliders.

    See Also
    DistanceInfo
    TryGetClosestCollider(IXRInteractable, Vector3, out DistanceInfo)
    ClosestPoint
    Back to top
    Terms of use
    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