代码语言:javascript复制
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Vuforia;
public class ArCamFoucs : MonoBehaviour {
// Use this for initialization
void Start () {
bool focusModeSet = CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO); if (!focusModeSet)
{
Debug.Log("Failed to set focus mode (unsupported mode).");
}
}
// Update is called once per frame
void Update () {
if (Application.platform == RuntimePlatform.WindowsEditor)
{
//if (Input.GetMouseButtonUp(0))
//{
// CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_TRIGGERAUTO);
// StartCoroutine(RestoreOriginalFocusMode());
//}
}
else
{
if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Ended)
{
CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_TRIGGERAUTO);
StartCoroutine(RestoreOriginalFocusMode());
}
}
}
private IEnumerator RestoreOriginalFocusMode()
{
yield return new WaitForSeconds(1.5f);
CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO);
}
}