docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class CardinalUtility

    Utility functions related to Cardinal directions.

    Inheritance
    object
    CardinalUtility
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEngine.XR.Interaction.Toolkit.Inputs
    Assembly: Unity.XR.Interaction.Toolkit.dll
    Syntax
    public static class CardinalUtility

    Methods

    GetNearestCardinal(Vector2)

    Get the nearest cardinal direction for a given value.

    Declaration
    public static Cardinal GetNearestCardinal(Vector2 value)
    Parameters
    Type Name Description
    Vector2 value

    Input vector, such as from a thumbstick.

    Returns
    Type Description
    Cardinal

    Returns the nearest Cardinal direction.

    Remarks

    Arbitrarily biases towards North and South to disambiguate when angle is exactly equidistant between directions.

    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)