Class ARSession
- 네임스페이스
- easyar
- 어셈블리
- EasyAR.Sense.dll
A MonoBehaviour that controls an AR session in the scene. A session contains a group of components assembled into ARAssembly and controls the data flow of the entire lifecycle. This component is the entry point for AR. Multiple active instances are not allowed at the same time.
All functions of EasyAR components can be used only after StartSession().
The relative transform between Camera and some AR components is controlled by session. One of the objects is called CenterObject; it stays still in the scene, and other objects move relative to this CenterObject. This object is selected according to the value of CenterMode. For more details, see the description of ARSession.ARCenterMode.
[DefaultExecutionOrder(-2147483648)]
[DisallowMultipleComponent]
[RequireComponent(typeof(EasyARController), typeof(DiagnosticsController))]
[RequireComponent(typeof(FrameRecorder), typeof(FramePlayer), typeof(CameraImageRenderer))]
public class ARSession : MonoBehaviour
- 상속
-
ARSession
필드
AutoStart
Automatically starts session when MonoBehaviour.Start is called. If set to false, you need to manually call StartSession() to start session.
[SerializeField]
[HideInInspector]
public bool AutoStart
CenterMode
AR center mode. It can be modified at any time and takes effect immediately. If the specified mode is unavailable, it will be automatically changed to an available mode.
[SerializeField]
[HideInInspector]
public ARSession.ARCenterMode CenterMode
HorizontalFlip
Horizontal mirror rendering mode. It can be modified at any time and takes effect immediately. Available only when using image or object tracking.
[SerializeField]
[HideInInspector]
public ARSession.FlipOptions HorizontalFlip
속성
AssembleOptions
Session assemble options. They need to be set before Assemble() (StartSession() will implicitly call it if it has not been called before).
public AssembleOptions AssembleOptions { get; }
Assembly
Assembly of AR components.
public ARAssembly Assembly { get; }
AvailableCenterMode
Center modes available for the current session.
public IReadOnlyList<ARSession.ARCenterMode> AvailableCenterMode { get; }
CenterObject
The center object used by this session in the current frame.
This object represents the object that does not move in Unity space, or the parent node of that object. It may be Origin, Camera, or a `target`. A `Target` can be an object containing the TargetController component. When using Sparse Spatial Map and EasyAR Mega, the actual center GameObject is the specific localized map or block object under the root node, and CenterObject is the parent node of this object. For more details, see the description of ARSession.ARCenterMode.
public GameObject CenterObject { get; }
Diagnostics
Session diagnostics component.
public DiagnosticsController Diagnostics { get; }
Origin
Session origin when any motion tracking feature is running.
It will be automatically selected from the scene, or created by EasyAR or a third-party frame source extension if it does not exist. When using a built-in frame source, if the XROrigin of the Unity XR framework exists, it will be selected. If the AR Foundation package does not exist, only XR Origin with the default tree structure will be selected.
public GameObject Origin { get; }
Report
Session report. It can be viewed after assemble completes and is updated when session state changes. It is used to view detailed information about session damage, component availability, and other details.
public SessionReport Report { get; }
SpecificTargetCenter
Manually specified center object. When CenterMode == SpecificTarget, CenterObject will be set to this object. It can be modified at any time and takes effect immediately.
This object must contain the TargetController component.
public GameObject SpecificTargetCenter { get; set; }
State
Current session state.
public ARSession.SessionState State { get; }
TrackingStatus
Motion tracking status when any motion tracking feature is running.
public Optional<MotionTrackingStatus> TrackingStatus { get; }
enabled
활성화/비활성화합니다 output while session is running. When disabled, session does not output, and the camera image (if controlled by EasyAR) and transforms of all session objects are not updated.
public bool enabled { get; set; }
메서드
Assemble()
조립합니다 session using AssembleOptions. If it has been called, it will be automatically called in StartSession().
public IEnumerator Assemble()
ImageCoordinatesFromScreenCoordinates(Vector2)
Transforms from the screen coordinate system ([0, 1]^2) to the image coordinate system ([0, 1]^2). pointInView needs to be normalized to [0, 1]^2. Not available on headsets.
public Optional<Vector2> ImageCoordinatesFromScreenCoordinates(Vector2 pointInView)
매개 변수
pointInView
StartSession()
시작합니다 session. If AutoStart is true, it is automatically called in MonoBehaviour.Start.
public void StartSession()
StopSession(bool)
중지합니다 starting session. All transform updates and image rendering updates will stop. You can use rotation to keep the last frame image when stopped, but this is effective only when EasyAR controls image rendering (not effective for AR Foundation, headsets, etc.).
public void StopSession(bool keepLastFrame)
매개 변수
keepLastFrame
이벤트
AssembleUpdate
Session Assemble() update event. During one Assemble() (StartSession() will implicitly call it if it has not been called before), this event is triggered 1-2 times. The first time is when Assemble completes. If the device list update has already completed when Assemble completes, there will be no second call; otherwise the second call occurs when the device list update completes.
public event Action<SessionReport.AvailabilityReport> AssembleUpdate
InputFrameUpdate
Input frame update event, triggered only when the InputFrame displayed by session changes. On headsets, this event does not affect session running, and if a passthrough image exists, its rendering is completed by the device.
On headset devices, this event is triggered only by plugin version >= 4003.1.
public event Action<InputFrame> InputFrameUpdate
PostSessionUpdate
Session update finished event. Its frequency is the same as MonoBehaviour.Update (on headsets, the extension author needs to implement it correctly). When this event is triggered, all transform changes controlled by EasyAR in this frame have completed.
public event Action PostSessionUpdate
StateChanged
Event for session State changes.
public event Action<ARSession.SessionState> StateChanged