1.前后相机切换
示例代码:
using UnityEngine;
using System.Collections;
using Vuforia;
public class CameraManager : MonoBehaviour
{
bool Is_CAMERA_FRONT;
private void Start()
{
Is_CAMERA_FRONT = false;
}
public void ChangeCamera()
{
Is_CAMERA_FRONT = !Is_CAMERA_FRONT;
if (Is_CAMERA_FRONT)
{
CameraDevice.Instance.Stop();
CameraDevice.Instance.Deinit();
CameraDevice.Instance.Init(CameraDevice.CameraDirection.CAMERA_FRONT);
CameraDevice.Instance.Start();
}
else
{
CameraDevice.Instance.Stop();
CameraDevice.Instance.Deinit();
CameraDevice.Instance.Init(CameraDevice.CameraDirection.CAMERA_BACK);
CameraDevice.Instance.Start();
}
}
}
2.相机对焦
官方文档:Camera-Focus-Modes
示例代码:
using UnityEngine;
using System.Collections;
public class AutoFocus : MonoBehaviour
{
void Start()
{ Vuforia.CameraDevice.Instance.SetFocusMode(Vuforia.CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO);
Vuforia.CameraDevice.Instance.Start();
}
void Update()
{
#if UNITY_EDITOR
if (Input.GetMouseButtonUp(0))
#elif UNITY_ANDROID || UNITY_IPHONE
if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began)
#endif
{
Vuforia.CameraDevice.Instance.SetFocusMode(Vuforia.CameraDevice.FocusMode.FOCUS_MODE_TRIGGERAUTO);
Vuforia.CameraDevice.Instance.Start();
}
}
}
3.闪光灯应用
CameraDevice.Instance.SetFlashTorchMode(true);