using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Vuforia;
using UnityEngine.UI;
public class OpenPhoneLight : MonoBehaviour
{
public Button flashBtn;//闪光灯的开关按钮
void Start()
{
var vuforia = VuforiaARController.Instance;
//开始回调
vuforia.RegisterVuforiaStartedCallback(OnVuforiaStarted);
flashBtn.onClick.AddListener(SwichtFlash);
}
private void OnVuforiaStarted()
{
//设置摄像机 自动对焦 自动对焦模式
Vuforia.CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO);
}
public void OnFocusModeClick()
{
//对焦模式
CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_TRIGGERAUTO);
}
bool openPhoneLight = false;//闪光灯的状态
public void SwichtFlash()
{
if (openPhoneLight == false)
{
CameraDevice.Instance.SetFlashTorchMode(true);
openPhoneLight = true;
}
else
{
CameraDevice.Instance.SetFlashTorchMode(false);
openPhoneLight = false;
}
}
}
来源:CSDN
作者:weixin_43109909
链接:https://blog.csdn.net/weixin_43109909/article/details/104117619