I know this is a old post, but since I'm having some issues, .
I drag the script below from "CameraFocusController.zip" in unity and then an error message appears: Member 'FocusMode.FOCUS_MODE_CONTINUOUSAUTO' cannot be accessed with an instance reference qualify it with a type name instead.
Please help!
thanks a lot
using UnityEngine;
using System.Collections;
using Vuforia;
public class CameraFocusController : MonoBehaviour {
private bool mVuforiaStarted = false;
void Start ()
{
VuforiaBehaviour vuforia = (VuforiaBehaviour)FindObjectOfType(typeof(VuforiaBehaviour));
if (vuforia != null)
vuforia.RegisterVuforiaStartedCallback(StartAfterVuforia);
}
private void StartAfterVuforia()
{
mVuforiaStarted = true;
SetAutofocus();
}
void OnApplicationPause(bool pause)
{
if (!pause)
{
// App resumed
if (mVuforiaStarted)
{
// App resumed and vuforia already started
// but lets start it again...
SetAutofocus(); // This is done because some android devices lose the auto focus after resume
// this was a bug in vuforia 4 and 5. I haven't checked 6, but the code is harmless anyway
}
}
}
private void SetAutofocus()
{
if (CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO))
{
Debug.Log("Autofocus set");
}
else
{
// never actually seen a device that doesn't support this, but just in case
Debug.Log("this device doesn't support auto focus");
}
}
}
Hey there,
I suggest refraining from older code, especially when using Vuforia Engine v10 and above. The API has changed which can cause the issues you're reporting.
I suggest checking out this article: https://library.vuforia.com/platform-support/working-camera-unity
Kind regards,
Patrick Scheper
Technical Community Manager