docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct ArSession

    Represents the context for an ARCore session.

    Implements
    IEquatable<ArSession>
    Inherited Members
    ValueType.ToString()
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: UnityEngine.XR.ARCore
    Assembly: Unity.XR.ARCore.dll
    Syntax
    public struct ArSession : IEquatable<ArSession>
    Remarks

    This is an opaque object that represents a native ArSession.

    Properties

    playbackStatus

    (Read Only) The playback status.

    Declaration
    public ArPlaybackStatus playbackStatus { get; }
    Property Value
    Type Description
    ArPlaybackStatus

    Whether or not the session is playing back a recording (or has stopped because of an error).

    See Also
    beforeSetConfiguration
    ARCoreBeforeSetConfigurationEventArgs
    beforeGetCameraConfiguration
    ARCoreBeforeGetCameraConfigurationEventArgs

    recordingStatus

    (Read Only) The current recording status.

    Declaration
    public ArRecordingStatus recordingStatus { get; }
    Property Value
    Type Description
    ArRecordingStatus

    Whether or not the session is recording (or has stopped because of an error).

    See Also
    beforeSetConfiguration
    ARCoreBeforeSetConfigurationEventArgs
    beforeGetCameraConfiguration
    ARCoreBeforeGetCameraConfigurationEventArgs

    Methods

    AsIntPtr()

    Gets the underlying native pointer for this ArSession.

    Declaration
    public IntPtr AsIntPtr()
    Returns
    Type Description
    IntPtr

    Returns the underlying native pointer for this ArSession.

    See Also
    beforeSetConfiguration
    ARCoreBeforeSetConfigurationEventArgs
    beforeGetCameraConfiguration
    ARCoreBeforeGetCameraConfigurationEventArgs

    Equals(object)

    Tests for equality.

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    object obj

    An object to compare against.

    Returns
    Type Description
    bool

    Returns true if obj is an ArSession and it compares equal to this one using Equals(ArSession).

    Overrides
    ValueType.Equals(object)
    See Also
    beforeSetConfiguration
    ARCoreBeforeSetConfigurationEventArgs
    beforeGetCameraConfiguration
    ARCoreBeforeGetCameraConfigurationEventArgs

    Equals(ArSession)

    Tests for equality.

    Declaration
    public bool Equals(ArSession other)
    Parameters
    Type Name Description
    ArSession other

    The ArSession to compare against.

    Returns
    Type Description
    bool

    Returns true if the underlying native pointers are the same. Returns false otherwise.

    Remarks

    Two ArSessions are considered equal if their underlying pointers are equal.

    See Also
    beforeSetConfiguration
    ARCoreBeforeSetConfigurationEventArgs
    beforeGetCameraConfiguration
    ARCoreBeforeGetCameraConfigurationEventArgs

    FromIntPtr(IntPtr)

    Creates an ArSession from an existing native pointer. The native pointer must point to an existing ArSession.

    Declaration
    public static ArSession FromIntPtr(IntPtr value)
    Parameters
    Type Name Description
    IntPtr value

    A pointer to an existing native ArSession.

    Returns
    Type Description
    ArSession

    Returns an ArSession whose underlying native pointer is value.

    See Also
    beforeSetConfiguration
    ARCoreBeforeSetConfigurationEventArgs
    beforeGetCameraConfiguration
    ARCoreBeforeGetCameraConfigurationEventArgs

    GetHashCode()

    Generates a hash code suitable for use with a HashSet or Dictionary

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int

    Returns a hash code for this ArSession.

    Overrides
    ValueType.GetHashCode()
    See Also
    beforeSetConfiguration
    ARCoreBeforeSetConfigurationEventArgs
    beforeGetCameraConfiguration
    ARCoreBeforeGetCameraConfigurationEventArgs

    SetPlaybackDataset(string)

    Sets an MP4 dataset file to playback instead of live camera feed.

    Declaration
    public ArStatus SetPlaybackDataset(string path)
    Parameters
    Type Name Description
    string path

    A file path to a MP4 dataset file or null to use the live camera feed.

    Returns
    Type Description
    ArStatus
    • Returns Success if successful.
    • Returns ErrorSessionNotPaused if called when session is not paused.
    • Returns ErrorSessionUnsupported if playback is incompatible with selected features.
    • Returns ErrorPlaybackFailed if an error occurred with the MP4 dataset file such as not being able to open the file or the file is unable to be decoded.
    Remarks

    Restrictions:

    • Can only be called while the session is paused. Playback of the MP4 dataset file starts once the session is resumed.
    • The MP4 dataset file must use the same camera facing direction as is configured in the session.

    When an MP4 dataset file is set:

    • All existing trackables (i.e., anchors and trackables) immediately enter tracking state TrackingState.None.
    • The desired focus mode is ignored, and does not affect the previously recorded camera images.
    • The current camera configuration is immediately set to the default for the device the MP4 dataset file was recorded on.
    • Calls to retrieve the supported camera configurations return camera configs supported by the device the MP4 dataset file was recorded on.
    • Setting a previously obtained camera config has no effect.
    See Also
    beforeSetConfiguration
    ARCoreBeforeSetConfigurationEventArgs
    beforeGetCameraConfiguration
    ARCoreBeforeGetCameraConfigurationEventArgs

    StartRecording(ArRecordingConfig)

    Starts a new MP4 dataset file recording that is written to the specific filesystem path.

    Declaration
    public ArStatus StartRecording(ArRecordingConfig recordingConfig)
    Parameters
    Type Name Description
    ArRecordingConfig recordingConfig

    The configuration defined for recording.

    Returns
    Type Description
    ArStatus

    Returns Success if successful. Returns one of the following values otherwise: - ErrorIllegalState - ErrorInvalidArgument - ErrorRecordingFailed

    Remarks

    Existing files are overwritten.

    The MP4 video stream (VGA) bitrate is 5Mbps (40Mb per minute).

    Recording introduces additional overhead and may affect app performance.

    See Also
    beforeSetConfiguration
    ARCoreBeforeSetConfigurationEventArgs
    beforeGetCameraConfiguration
    ARCoreBeforeGetCameraConfigurationEventArgs

    StopRecording()

    Stops recording and flushes unwritten data to disk. The MP4 dataset file is ready to read after this call.

    Declaration
    public ArStatus StopRecording()
    Returns
    Type Description
    ArStatus

    Returns Success if successful. Returns ErrorRecordingFailed otherwise.

    Remarks

    Recording can be stopped automatically when the session is paused, if auto stop is enabled via SetAutoStopOnPause(ArSession, bool). Recording errors that would be thrown in StopRecording() are silently ignored on session pause.

    See Also
    beforeSetConfiguration
    ARCoreBeforeSetConfigurationEventArgs
    beforeGetCameraConfiguration
    ARCoreBeforeGetCameraConfigurationEventArgs

    Operators

    operator ==(ArSession?, ArSession?)

    Tests for equality.

    Declaration
    public static bool operator ==(ArSession? lhs, ArSession? rhs)
    Parameters
    Type Name Description
    ArSession? lhs

    The nullable ArSession to compare with rhs.

    ArSession? rhs

    The nullable ArSession to compare with lhs.

    Returns
    Type Description
    bool

    Returns true if any of these conditions are met: - lhs and rhs are both not null and their underlying pointers are equal. - lhs is null and rhs's underlying pointer is null. - rhs is null and lhs's underlying pointer is null. - Both lhs and rhs are null.

     Returns false otherwise.
    
    Remarks

    This equality operator lets you to compare an ArSession with null to determine whether its underlying pointer is null. This allows for a more natural comparison with the native ARCore object:

    bool TestForNull(ArSession obj)
    {
        if (obj == null)
        {
            // obj.AsIntPtr() is IntPtr.Zero
        }
    }
    See Also
    beforeSetConfiguration
    ARCoreBeforeSetConfigurationEventArgs
    beforeGetCameraConfiguration
    ARCoreBeforeGetCameraConfigurationEventArgs

    operator ==(ArSession, ArSession)

    Tests for equality. Same as Equals(ArSession).

    Declaration
    public static bool operator ==(ArSession lhs, ArSession rhs)
    Parameters
    Type Name Description
    ArSession lhs

    The ArSession to compare with rhs.

    ArSession rhs

    The ArSession to compare with lhs.

    Returns
    Type Description
    bool

    Returns true if lhs is equal to rhs using Equals(ArSession). Returns false otherwise.

    See Also
    beforeSetConfiguration
    ARCoreBeforeSetConfigurationEventArgs
    beforeGetCameraConfiguration
    ARCoreBeforeGetCameraConfigurationEventArgs

    explicit operator IntPtr(ArSession)

    Casts an ArSession to its underlying native pointer.

    Declaration
    public static explicit operator IntPtr(ArSession session)
    Parameters
    Type Name Description
    ArSession session

    The ArSession to cast.

    Returns
    Type Description
    IntPtr

    Returns the underlying native pointer for session

    See Also
    beforeSetConfiguration
    ARCoreBeforeSetConfigurationEventArgs
    beforeGetCameraConfiguration
    ARCoreBeforeGetCameraConfigurationEventArgs

    operator !=(ArSession?, ArSession?)

    Tests for inequality.

    Declaration
    public static bool operator !=(ArSession? lhs, ArSession? rhs)
    Parameters
    Type Name Description
    ArSession? lhs

    The native object to compare with rhs.

    ArSession? rhs

    The native object to compare with lhs.

    Returns
    Type Description
    bool

    Returns false if any of these conditions are met: - lhs and rhs are both not null and their underlying pointers are equal. - lhs is null and rhs's underlying pointer is null. - rhs is null and lhs's underlying pointer is null. - Both lhs and rhs are null.

     Returns true otherwise.
    
    Remarks

    This inequality operator lets you to compare an ArSession with null to determine whether its underlying pointer is null. This allows for a more natural comparison with the native ARCore object:

    bool TestForNull(ArSession obj)
    {
        if (obj != null)
        {
            // obj.AsIntPtr() is not IntPtr.Zero
        }
    }
    See Also
    beforeSetConfiguration
    ARCoreBeforeSetConfigurationEventArgs
    beforeGetCameraConfiguration
    ARCoreBeforeGetCameraConfigurationEventArgs

    operator !=(ArSession, ArSession)

    Tests for inequality. Same as the negation of Equals(ArSession).

    Declaration
    public static bool operator !=(ArSession lhs, ArSession rhs)
    Parameters
    Type Name Description
    ArSession lhs

    The ArSession to compare with rhs.

    ArSession rhs

    The ArSession to compare with lhs.

    Returns
    Type Description
    bool

    Returns false if lhs is equal to rhs using Equals(ArSession). Returns true otherwise.

    See Also
    beforeSetConfiguration
    ARCoreBeforeSetConfigurationEventArgs
    beforeGetCameraConfiguration
    ARCoreBeforeGetCameraConfigurationEventArgs

    Implements

    IEquatable<T>

    See Also

    beforeSetConfiguration
    ARCoreBeforeSetConfigurationEventArgs
    beforeGetCameraConfiguration
    ARCoreBeforeGetCameraConfigurationEventArgs
    In This Article
    Back to top
    Copyright © 2024 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)