Calling the device camera's webcamtexture on googleVR can't get the camera

The unity version is 2019 and earlier versions
. This problem has plagued me for a long time. Domestic websites have never been able to find a solution. Finally, I found a similar problem on github. Here is the link .
Phenomenon description: When VR Supported is not turned on, the camera can be turned on normally after calling the camera. Before turning on the camera, a dialog box prompting whether to allow calling will pop up. When VR Supported is turned on and a Card Board is added, the camera cannot be invoked, and a dialog box prompting permission will not pop up.
insert image description here

Cause of the problem: When VR Supported is turned on, the permission request of the camera may be automatically removed, and the permission is not turned on.
Problem solving:
1. If it is a unity project to add permissions, open the Project Setting panel, and check the Custom main Manifest under Player. Follow the prompt path to open the AndroidManifest.xml file.
insert image description here
As shown in the figure, add the following code in the corresponding position of the file.

<meta-data android:name="unityplayer.SkipPermissionsDialog" android:value="false"/>

<!-- camera permission --> 
<uses-permission android:name="android.permission.CAMERA"/> 
<uses-permission android:name="android.hardware.camera"/> 
<uses-feature android:name="android.hardware.camera"/> 
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> 

insert image description here
2. If the final apk package platform is
to find AndroidManifest.xml and AndroidManifest-Cardboard.xml (if any) in Android Studio, add the above permission code in it

Guess you like

Origin blog.csdn.net/qq_37619255/article/details/129021820