ARFoundationFrameSource Class¶
Description¶
在场景中将AR Foundation 的输出连接到EasyAR输入的自定义frame source。通过EasyAR Sense的自定义相机功能提供AR Foundation支持。
这个frame source是一种运动跟踪设备,在 ARSession 中会输出运动数据。
为了使用这个frame source, AR Foundation
是必需的。你需要根据官方文档配置AR Foundation。
这个frame source会使用 ARFoundation.ARSession.CheckAvailability
来检查可用性。在可用性检查中, FrameSource.Camera 和 XROriginBasedFrameSource.XROrigin (或 CompatibleAROriginFrameSource.ARSessionOrigin )也是需要的,如果没有事先设置,会自动从场景物体中选择。如果要在运行时选择 frame source,可以deactive AR Foundation使用的所有GameObject,并设置所有frame source可用性检查所需要的数值,然后在这个frame source被选择后active AR Foundation 的GameObject。
MonoBehaviour Messages¶
protected override void OnEnable() |
protected override void OnDisable() |
protected override void Awake() |
protected virtual void OnDestroy() |
protected virtual void OnApplicationPause(bool pause) |
Fields¶
EnableColorInput¶
- C#
public bool EnableColorInput
是否使用彩色图像作为frame输入。彩色图像在需要录制彩色eif文件的时候可以使用。所有EasyAR算法都不需要使用彩色图像。
AttemptUpdate¶
- C#
public bool AttemptUpdate
如果设备支持AR Foundation但没有必要的软件,一些平台允许提示用户安装或更新软件。如果变量值为true,会尝试软件更新。如果系统中没有安装软件或软件过期,且变量值为false,这个frame source将是不可用的。
Properties¶
IsAvailable¶
- C#
public override Optional<bool> IsAvailable { get; }
当前frame source是否可用。
如果数值等于null,需要调用 FrameSource.CheckAvailability ,数值将在 Coroutine 结束后可以访问。这个属性会在 ARComponentPicker 选择frame source的时候使用。
ARSessionOrigin¶
- C#
public UnityEngine.XR.ARFoundation.ARSessionOrigin ARSessionOrigin { get; set; }
相机运动的相对物体,如果没设置,将会自动从场景中获取。
Origin¶
- C#
public override GameObject Origin { get; }
ARSession 的原点,如果frame source可以输出运动跟踪数据。
每种运动跟踪frame source都有自己的方法来设置包含特定组件的原点物体。如果原点未设置,一些frame source会从场景中active的物体中自动选择可以使用的物体或创建一个新的物体。
XROrigin¶
- C#
public Unity.XR.CoreUtils.XROrigin XROrigin { get; set; }
XR Origin。
AvailableCenterMode¶
- C#
public override IReadOnlyList< ARSession.ARCenterMode > AvailableCenterMode { get; }
该frame source可以使用的中心模式。
ReceivedFrameCount¶
- C#
public int ReceivedFrameCount { get; protected set; }
从设备获取到的帧计数。通常在debug中使用。如果这个数值停止增长,通常是硬件问题,某些设备(比如Nreal)重新插拔可能能解决。
Camera¶
- C#
public virtual Camera Camera { get; set; }
在一个 ARSession 中被该frame source使用的 Camera 。
每种frame source都有自己的方法来检查camera是否可用,设置不可用的camera将会被拒绝。这个属性会在 ARComponentPicker 选择frame source时用来判断frame source是否可用。在这个过程中,如果数值没有设置,一些frame source会从场景中active的物体中自动选择可以使用的 Camera 。你可以在session start前设置可用的 Camera 。如果这个frame source被 ARSession 选用,这个数值将在session ready后无法修改。
Methods¶
CheckAvailability¶
- C#
public override System.Collections.IEnumerator CheckAvailability()
FrameSource.IsAvailable 等于null时用于检查frame source是否可用的 Coroutine 。