在 Unity 中,为什么我可以通过按下按钮将相机切换到 WorldView,但不能在启动或更新循环中同时使用 Face Manager?

问题描述 投票:0回答:2

我正在开发一款 Unity AR 游戏,我想开始使用面部管理器在面向世界的相机上跟踪面部姿势。我知道您可以使用世界相机跟踪面部姿势,因为我在 ar-foundation-samples 项目中看到过它。需要注意的是,您必须先以面向用户的模式启动,然后在应用程序运行后按下按钮切换到面向世界的模式。我希望它从 World-Facing 相机开始,但每次我尝试在运行 Face Manager 的情况下执行此操作时,它都不起作用;相机根本不亮。我的问题是,为什么我可以通过单击按钮将我的面部姿势跟踪从面向用户切换到面向世界,但我不能通过 Start() 或 Update() 方法做同样的事情?

public class FaceController : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        /*This won't switch the camera*/        
        camManager.requestedFacingDirection = CameraFacingDirection.World;
    }

    private void OnEnable()
    {
        
    }

    public ARCameraManager camManager;
    public ARSession aRSession;
    bool trigger;
    bool trigger2;

    public void SwitchMode()
    {
        /*This will switch the camera when called by a button press */
        camManager.requestedFacingDirection = CameraFacingDirection.World;
    }

    // Update is called once per frame
    void Update()
    {
      
      
    }
}
c# unity3d mobile augmented-reality arcore
2个回答
0
投票

所以我发现你只能在第一帧通过后才能切换相机。根据 derHugo 下面的评论,我认为最好的解决方案是协程如下:

IEnumerator switchCamera()
{

    yield return null;
    yield return null;
    camManager.requestedFacingDirection = CameraFacingDirection.World;
    
}

-1
投票

有了建议,我可以切换到世界观,但它会停用面部跟踪?关于世界观 + Facetracking 的任何进一步建议?

© www.soinside.com 2019 - 2024. All rights reserved.