You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The usage of WebCamTexture in Runtime\AvatarCreator\Scripts\UI\Elements\PhotoCaptureElement.cs causes Unity to add the camera permission to our app's AndroidManifest.xml. As camera access is not allowed by Meta for their Quest platform, builds of our app cannot be uploaded to the Quest Store or App Lab.
Copy the RPM package at [Your project]\Library\PackageCache\com.readyplayerme.core and save it in another location.
Remove the package from your Unity project using the Package Manager.
Drag the RPM package folder to your project's Assets folder.
Install GLTFast from the Package Manager (check this guide).
Comment out the problematic lines from com.readyplayerme.core\Runtime\AvatarCreator\Scripts\UI\Elements\PhotoCaptureElement.cs like so:
usingSystem.Linq;usingSystem.Threading;usingSystem.Threading.Tasks;usingUnityEngine;
#if UNITY_ANDROIDusingUnityEngine.Android;
#endif
usingUnityEngine.Events;usingUnityEngine.UI;
#pragma warning disable CS1998namespaceReadyPlayerMe.AvatarCreator{/// <summary>/// A Unity MonoBehaviour class for capturing photos from the device's camera./// Allows starting and stopping the camera, capturing photos, and handling camera permissions./// </summary>publicclassPhotoCaptureElement:MonoBehaviour{[Header("Settings")][SerializeField]privateRawImagecameraTextureTarget;[SerializeField]privateboolinitializeOnEnable=true;[Space(5)][Header("Events")]publicUnityEvent<Texture2D>OnPhotoCaptured;// private WebCamTexture cameraTexture;privateboolisInitialized;privateintvideoRotationAngle;privateboolvideoVerticallyMirrored;privateCancellationTokenSourcectxSource;privatevoidOnEnable(){if(initializeOnEnable){StartCamera();}}privatevoidOnDisable(){ctxSource?.Cancel();StopCamera();}/// <summary>/// Starts the device's camera, requesting camera permissions if needed./// </summary>publicasyncvoidStartCamera(){awaitRequestCameraPermission();if(!isInitialized){InitializeCamera();}// if (cameraTexture != null && !cameraTexture.isPlaying)// {// cameraTexture.Play();// // var currentRotation = cameraTextureTarget.transform.rotation;// cameraTextureTarget.transform.rotation = Quaternion.Euler(currentRotation.eulerAngles.x, currentRotation.eulerAngles.y, cameraTexture.videoRotationAngle);// // if (!cameraTexture.videoVerticallyMirrored)// {// cameraTextureTarget.transform.localScale = new Vector3(-1, 1, 1);// }// }}/// <summary>/// Stops the device's camera./// </summary>publicvoidStopCamera(){// if (cameraTexture != null && cameraTexture.isPlaying)// {// cameraTexture.Stop();// }}/// <summary>/// Takes a photo from the camera and invokes the onPhotoCaptured event with the captured texture./// </summary>publicvoidTakePhoto(){// if (cameraTexture == null || !cameraTexture.isPlaying)// return;// // var texture = new Texture2D(cameraTextureTarget.texture.width, cameraTextureTarget.texture.height, TextureFormat.ARGB32, false);// texture.SetPixels(cameraTexture.GetPixels());// texture.Apply();// // OnPhotoCaptured?.Invoke(texture);}/// <summary>/// Requests camera permissions from the user for IOS and Android devices./// </summary>privateasyncTaskRequestCameraPermission(){ctxSource?.Cancel();ctxSource=newCancellationTokenSource();
#if UNITY_ANDROIDif(!Permission.HasUserAuthorizedPermission(Permission.Camera)){Permission.RequestUserPermission(Permission.Camera);}while(!Permission.HasUserAuthorizedPermission(Permission.Camera)&&!ctxSource.IsCancellationRequested){awaitTask.Yield();}
#elif UNITY_IOSif(!Application.HasUserAuthorization(UserAuthorization.WebCam)){varasync=Application.RequestUserAuthorization(UserAuthorization.Microphone);while(!async.isDone &&!ctxSource.IsCancellationRequested){awaitTask.Yield();}}
#endif
}/// <summary>/// Finds the device's camera and sets up the camera texture./// </summary>privatevoidInitializeCamera(){// var webCamDevice = GetWebCamDevice();// SetupPhotoBoothTexture(webCamDevice?.name);// isInitialized = true;}/// <summary>/// Sets up the camera texture with the provided texture name./// </summary>/// <param name="textureName">The name for the created WebCamTexture</param>privatevoidSetupPhotoBoothTexture(stringtextureName){// var size = cameraTextureTarget.rectTransform.sizeDelta;// cameraTexture = new WebCamTexture(textureName, (int) size.x, (int) size.y);// cameraTextureTarget.texture = cameraTexture;}/// <summary>/// Tries to find the device's front-facing camera or returns default camera./// </summary>/// <returns>Returns the WebCamDevice if found</returns>// private static WebCamDevice? GetWebCamDevice()// {// var devices = WebCamTexture.devices;// // if (devices.Length == 0)// return null;// // var webCamDevice = devices.FirstOrDefault(device => device.isFrontFacing);// // return webCamDevice.Equals(default(WebCamDevice)) ? devices[0] : webCamDevice;// }}}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
The usage of
WebCamTexture
inRuntime\AvatarCreator\Scripts\UI\Elements\PhotoCaptureElement.cs
causes Unity to add the camera permission to our app'sAndroidManifest.xml
. As camera access is not allowed by Meta for their Quest platform, builds of our app cannot be uploaded to the Quest Store or App Lab.See issue #244.
For those looking for a solution:
[Your project]\Library\PackageCache\com.readyplayerme.core
and save it in another location.Assets
folder.GLTFast
from the Package Manager (check this guide).com.readyplayerme.core\Runtime\AvatarCreator\Scripts\UI\Elements\PhotoCaptureElement.cs
like so:Beta Was this translation helpful? Give feedback.
All reactions