Struct ArSession
Represents the context for an ARCore session.
Inherited Members
Namespace: UnityEngine.XR.ARCore
Syntax
public struct ArSession : IEquatable<ArSession>
Remarks
This is an opaque object that represents a native ArSession.
Properties
IsNull
(Read Only) Indicates whether this ArSession is null
.
This property is deprecated. Use the equality operator (==
) to compare with null
instead.
Declaration
[Obsolete("Compare to null instead.")]
public readonly bool IsNull { get; }
Property Value
Type | Description |
---|---|
Boolean |
Null
Represents a null ArSession, i.e., one whose underlying native pointer is null
.
This property is obsolete. Use langword_csharp_default instead.
Declaration
[Obsolete("Use default instead.")]
public static readonly ArSession Null { get; }
Property Value
Type | Description |
---|---|
ArSession |
playbackStatus
(Read Only) The playback status.
Declaration
public readonly 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). |
recordingStatus
(Read Only) The current recording status.
Declaration
public readonly ArRecordingStatus recordingStatus { get; }
Property Value
Type | Description |
---|---|
ArRecordingStatus | Whether or not the session is recording (or has stopped because of an error). |
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. |
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 |
---|---|
Boolean | Returns |
Overrides
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 |
---|---|
Boolean | Returns |
Implements
Remarks
Two ArSessions are considered equal if their underlying pointers are equal.
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
|
GetHashCode()
Generates a hash code suitable for use with a HashSet
or Dictionary
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 | Returns a hash code for this ArSession. |
Overrides
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 |
Returns
Type | Description |
---|---|
ArStatus |
|
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.
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: |
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.
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, Boolean). Recording errors that would be thrown in StopRecording() are silently ignored on session pause.
Operators
Equality(Nullable<ArSession>, Nullable<ArSession>)
Tests for equality.
Declaration
public static bool operator ==(ArSession? lhs, ArSession? rhs)
Parameters
Type | Name | Description |
---|---|---|
Nullable<ArSession> | lhs | The nullable ArSession to compare with |
Nullable<ArSession> | rhs | The nullable ArSession to compare with |
Returns
Type | Description |
---|---|
Boolean | Returns true if any of these conditions are met:
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
}
}
Equality(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 |
ArSession | rhs | The ArSession to compare with |
Returns
Type | Description |
---|---|
Boolean | Returns |
Explicit(ArSession to IntPtr)
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 |
Inequality(Nullable<ArSession>, Nullable<ArSession>)
Tests for inequality.
Declaration
public static bool operator !=(ArSession? lhs, ArSession? rhs)
Parameters
Type | Name | Description |
---|---|---|
Nullable<ArSession> | lhs | The native object to compare with |
Nullable<ArSession> | rhs | The native object to compare with |
Returns
Type | Description |
---|---|
Boolean | Returns false if any of these conditions are met:
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
}
}
Inequality(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 |
ArSession | rhs | The ArSession to compare with |
Returns
Type | Description |
---|---|
Boolean | Returns |