I need to use the native Camera of an Android device in Unity Engine.
I already tried to use the WebCamTexture, but i need to use the Android flashlight at same time, and the WebCamTexture freezes when the flashlight starts.
I used this code to turn on the flashlight:
AndroidJavaClass cameraClass = new AndroidJavaClass("android.hardware.Camera");
androidCamera = cameraClass.CallStatic<AndroidJavaObject>("open", 0);
AndroidJavaObject cameraParameters = androidCamera.Call<AndroidJavaObject>("getParameters");
cameraParameters.Call("setFlashMode", "torch");
androidCamera.Call("setParameters", cameraParameters);
androidCamera.Call ("startPreview");
I think the WebCamTexture freezes because it's one instance of the android camera, and the Flashlight isn't called by the Unity, it's called by the android class, so i think it's another instance of the camera, and android does not support multiple instances of the camera.
So i think that i need to call the camera natively too, and pass it to Unity as a texture, but i don't know how to do this. Someone can help me please?
Thanks in advance.