docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class VisionOS

    Runtime scripting API for VisionOS.

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

    Methods

    GetLayerRenderer()

    Get the native pointer to the LayerRenderer currently being used for rendering, or IntPtr.Zero (null) if none exists. A LayerRenderer is provided by the system for communicating with the XR compositor.

    Declaration
    public static IntPtr GetLayerRenderer()
    Returns
    Type Description
    IntPtr

    The LayerRenderer currently being used for rendering, or IntPtr.Zero (null) if none exists.

    Remarks

    Note that the layer renderer is not immediately available on app start, or immediately after enabling Metal rendering. You may need to check if this is null for a few frames before a valid pointer is available. This API always returns IntPtr.Zero (null) in the Editor.

    IsImmersiveSpaceReady()

    Determine whether the immersive space for the app is ready. Return true in the Editor for testing purposes.

    Declaration
    public static bool IsImmersiveSpaceReady()
    Returns
    Type Description
    bool

    true if the immersive space is ready (or in the Editor when targeting visionOS). Otherwise, false.

    IsSimulator()

    Determine whether the app is running in the visionOS simulator. Treat the Editor targeting visionOS as running in simulator.

    Declaration
    public static bool IsSimulator()
    Returns
    Type Description
    bool

    true if the app is running in the visionOS Simulator. Otherwise, false.

    QueryAuthorizationStatus(VisionOSAuthorizationType)

    Query the current authorization status for a given authorization type.

    Declaration
    public static VisionOSAuthorizationStatus QueryAuthorizationStatus(VisionOSAuthorizationType type)
    Parameters
    Type Name Description
    VisionOSAuthorizationType type

    The authorization type to query.

    Returns
    Type Description
    VisionOSAuthorizationStatus

    The status of the queried authorization type.

    SetDepthRange(float, float)

    Set the range of values used for depth sorting. These values should match Camera.nearClipPlane and Camera.farClipPlane

    Declaration
    public static void SetDepthRange(float near, float far)
    Parameters
    Type Name Description
    float near

    The value for the near clipping plane.

    float far

    The value for the far clipping plane.

    SetMinimumFrameRepeatCount(IntPtr, int)

    Set the minimum number of additional times the system displays each frame. See Apple's documentation for cp_layer_renderer_set_minimum_frame_repeat_count for more details.

    Declaration
    public static void SetMinimumFrameRepeatCount(IntPtr layerRenderer, int repeatCount)
    Parameters
    Type Name Description
    IntPtr layerRenderer

    The layer renderer that is currently in use GetLayerRenderer().

    int repeatCount

    The desired repeat count.

    Remarks

    If your takes longer than 11ms to render a frame (assuming a target of 90hz), the compositor will repeat the last available frame. If you know you will not be able to consistently render at 90hz, you should use this API, along with UnityEngine.Application.targetFrameRate to consistently present frames at a lower rate, rather than a fluctuating rate which can cause issues with compositing and re-projection. Each repeated frame effectively increases the amount you will divide by 90 to decide on the appropriate target frame rate. For example, a value of 1 will show each frame two times, for a target frame rate of 45hz. A value of 2 will show each frame three times, for a target frame rate of 33hz. You can use GetTargetFrameRateForRepeatCount(int) to get the correct target frame rate value for a given repeat count. Adjusting this setting will inform the system that it should allow for more time between frames when calculating the optimal time to sample input and start rendering the next frame. If you do not use UnityEngine.Application.targetFrameRate, the XR plugin will still block Unity for enough time so that it does not out-pace the target frame rate, but your content may behave differently due to the fact that we are waiting at a different point in the player loop. In general, this API should be avoided until you see problems with animations or moving objects, and you should experiment with different settings until you see them resolved. The ideal outcome would be to optimize the scene so that it can consistently render at 90hz, but this is not always possible. You may also want to reduce the target frame rate (and increase frame repeat count) to save battery life, just like you would on other mobile platforms. This API requires a LayerRenderer, which is only available when using Metal Rendering with CompositorServices (Apple's XR compositor). It does not apply to RealityKit rendering.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    Thrown when repeatCount is less than 0.

    ArgumentNullException

    Thrown when layerRenderer is null.

    Events

    AuthorizationChanged

    Called when an ARKit authorization like hand tracking or world tracking changes status. Some examples of when this occurs:

    • On app start when initially querying the authorization status, if it was already requested
    • After querying authorization status, if it was not requested and the user allowed or declined
    • When the user changes authorizations in Settings and returns to the app
    Declaration
    public static event Action<VisionOSAuthorizationEventArgs> AuthorizationChanged
    Event Type
    Type Description
    Action<VisionOSAuthorizationEventArgs>
    In This Article
    • Methods
      • GetLayerRenderer()
      • IsImmersiveSpaceReady()
      • IsSimulator()
      • QueryAuthorizationStatus(VisionOSAuthorizationType)
      • SetDepthRange(float, float)
      • SetMinimumFrameRepeatCount(IntPtr, int)
    • Events
      • AuthorizationChanged
    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)