在start方法中加上代码如下:
void Start ()
{
var vuforia = VuforiaARController.Instance;
vuforia.RegisterVuforiaStartedCallback(OnVuforiaStarted);
vuforia.RegisterOnPauseCallback(OnPaused);
}
private void OnVuforiaStarted()
{
CameraDevice.Instance.SetFocusMode(
CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO);
}
private void OnPaused(bool paused)
{
if (!paused) // resumed
{
// Set again autofocus mode when app is resumed
CameraDevice.Instance.SetFocusMode(
CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO);
}
}
然后将该脚本挂载到ARCamera上。