[英]Unity3D. Accessing camera torch/flash issues - Torch works but can't access while streaming webcamtexture
我正在统一开发一个应用程序,在该应用程序中,用户可以使用其设备的相机拍照。 使用Unity的webcamtexture效果很好。 但是,不支持webcamtexture的闪存,因此我编写了自己的代码来访问设备Torch。 代码有效-但是在流式传输webcamtexture时不起作用(正在使用相机,因此java服务调用将返回错误)。 有人对如何解决此问题有任何建议吗? 有什么方法可以使用Unity的WebCamTexture激活相机手电筒吗? 这是激活相机割炬的代码:
AndroidJavaClass cameraClass = new AndroidJavaClass("android.hardware.Camera");
// This is an ugly hack to make Unity
// generate Camera permisions
WebCamDevice[] devices = WebCamTexture.devices;
int camID = 0;
camera = cameraClass.CallStatic<AndroidJavaObject>("open", camID);
// I'm pretty sure camera will never be null at this point
// It will either be a valid object or Camera.open would throw an exception
if (camera != null)
{
AndroidJavaObject cameraParameters = camera.Call<AndroidJavaObject>("getParameters");
cameraParameters.Call("setFlashMode","torch");
camera.Call("setParameters",cameraParameters);
Active = true;
}
尝试检查相机捕获套件是否统一。 它提供了Android所需的功能以及其源代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.