Gvr-unity-sdk: using device camera for webcamtexture on google cardboard not working

Created on 9 May 2018  路  4Comments  路  Source: googlevr/gvr-unity-sdk

Summary:
i want to use android camera from my Android Phone for the Raw Image in the Unity. I follow the instructions at https://www.youtube.com/watch?v=c6NXkZWXHnc for the simple apps and working.

but when i use "Virtual Reality Supported" on my builder and run it on my phone, the camera didn't work.

normal apps would ask for permission for this, but when i use vr mode, there is no any pop up messages. What should I do?

Found using:

  • Google VR SDK version:
  • Unity version: 2017.4.0f1
  • Phone manufacturer, model, and O/S version: Samsung Galaxy S7
  • Viewer manufacturer & model:

Steps to reproduce the issue:

  1. follow the tutorial at https://www.youtube.com/watch?v=c6NXkZWXHnc
  2. make the canvas -> render mode -> World space
  3. build and run on Android

Workarounds:

Additional comments:

question

All 4 comments

Check the PermissionsDemo scene, that might be what you're looking for

@vinhui hello bro, thank you for your suggestion

i try to run the scene on my devices, but when i trigger the "Request Permission Demo" button, the apps was forced close

i also change the permissionNames array to "android.permission.CAMERA" but the apps still crash. i also change the build API target to 5.1 (Lollipop)

any solution for it?

hello guys, i finally had a successful solution, just adding a few line

  1. open your AndroidManifest.xml (if you had) and AndroidManifest-Cardboard.xml
  2. add following line to your code inside your tags, to each opened xml

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

  1. add following line outside the tag but still inside tag

<!-- 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" />

  1. build try to run the apps in your mobile phone. At the first splash screen, the permission will pop up and allow it

i hope it would help you all

Happy to hear you found a solution.

Was this page helpful?
0 / 5 - 0 ratings