Last active
July 21, 2023 00:49
-
-
Save harmittaa/15f48554614ceac3e15eed78217828c1 to your computer and use it in GitHub Desktop.
CameraFocusController.cs for Vuforia ARCamera camera focus mode example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// full tutorial here: | |
// https://medium.com/@harmittaa/setting-camera-focus-mode-for-vuforia-arcamera-in-unity-6b3745297c3d | |
using UnityEngine; | |
using System.Collections; | |
using Vuforia; | |
public class CameraFocusController: MonoBehaviour { | |
// code from Vuforia Developer Library | |
// https://library.vuforia.com/articles/Solution/Camera-Focus-Modes | |
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); | |
} | |
} | |
} |
please update it for Vuforia 10.1
пожалуйста, обновите его для Vuforia 10.1
private void OnVuforiaStarted()
{
CameraDevice.Instance.SetFocusMode(FocusMode.FOCUS_MODE_CONTINUOUSAUTO);
}
here is update version for vuforia 10.7.2
https://github.com/motilordddd/CameraFocusController
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just works fine. Thank you for this excellent script.