我正在開發一個 Unity AR 游戲,我想開始使用面部管理器在面向世界的相機上跟蹤面部姿勢。我知道你可以使用 World Camera 跟蹤 Face Pose,因為我在 ar-foundation-samples 專案中看到過它。需要注意的是,您必須首先以面向用戶的模式啟動,然后在應用程式運行后按下按鈕切換到面向世界的模式。我希望它從面向世界的相機開始,但是每次我嘗試在面部管理器運行的情況下執行此操作時,它都不起作用;相機根本不亮。我的問題是,為什么我可以通過單擊按鈕將我的面部姿勢跟蹤從面向用戶切換到面向世界,但我不能通過 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()
{
}
}
uj5u.com熱心網友回復:
所以我發現你只能在第 1 幀過去后切換相機。根據下面derHugo的評論,我認為最好的解決方案是協程如下:
IEnumerator switchCamera()
{
yield return null;
yield return null;
camManager.requestedFacingDirection = CameraFacingDirection.World;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/351170.html
