text
stringlengths
0
1.11k
Instruction to toggle on the permission.Instruction to toggle on the permission.
When to request the runtime permission
As per the Android permission guidelines, it is recommended to request the permission only when using the functionality, and to provide a fallback if the user decides not to grant the permission.
Querying the Scene Model without having the permission granted will have the spatial data excluded from the returned data. OVRSceneManager returns 0 anchors if the user hasn’t run Space Setup or hasn’t granted the permission. With Verbose Logging enabled, a permission check is performed and logged to the console. OVRSceneModelLoader will automatically fall back to requesting Space Setup a single time, but will not perform any permission request.
Using Depth API also needs to have the permission granted.
Declare the permission
In order for the operating system to know that an app is interested in using a permission, it needs to be specified in the app’s Android manifest first. In Unity, the default way to manage all Quest permissions is through the OVRCameraRig’s OVRManager component, where there is a section titled Quest Features. Select Scene Support and regenerate the AndroidManifest.xml, using the Oculus toolbar.
If you would like to enter the permission directly into the manifest, add android:name="com.oculus.permission.USE_SCENE" within <uses-permission> xml tags.
An illustration of the permission flow UX.
Request the runtime permission
There are 2 options to request the runtime permission: either using a simple toggle in OVRManager, or using Unity’s Android Permission API. These should not be combined as one request may stop the other from completing as intended.
Option 1: request permission manually
Requesting the runtime permission is done through Unity’s Android API: Permission.HasUserAuthorizedPermission() and Permission.RequestUserPermission() with "com.oculus.permission.USE_SCENE" will query whether the user has granted the permission and request it, respectively.
const string spatialPermission = "com.oculus.permission.USE_SCENE";
bool hasUserAuthorizedPermission = UnityEngine.Android.Permission.HasUserAuthorizedPermission(spatialPermission);
if (!hasUserAuthorizedPermission) {
UnityEngine.Android.Permission.RequestUserPermission(spatialPermission);
}
Unity exposes Android’s permission callbacks. These callbacks can be subscribed to when requesting the permission, and will be fired when the relevant action happened.
void Denied(string permission) => Debug.Log($"{permission} Denied");
void Granted(string permission) => Debug.Log($"{permission} Granted");
void Start()
{
const string spatialPermission = "com.oculus.permission.USE_SCENE";
if (!UnityEngine.Android.Permission.HasUserAuthorizedPermission(spatialPermission))
{
var callbacks = new UnityEngine.Android.PermissionCallbacks();
callbacks.PermissionDenied += Denied;
callbacks.PermissionGranted += Granted;
// avoid callbacks.PermissionDeniedAndDontAskAgain. PermissionDenied is
// called instead unless you subscribe to PermissionDeniedAndDontAskAgain.
UnityEngine.Android.Permission.RequestUserPermission(spatialPermission, callbacks);
}
}
It is not advised to subscribe to the PermissionDeniedAndDontAskAgain callback, as it is unreliable on newer versions of Android. If the event is not subscribed to, then PermissionDenied is fired instead.
For more information, see Unity’s documentation on requesting Android runtime permissions.
Option 2: request the permission automatically via OVRManager
When using the OVRCameraRig, select the child OVRManager component and navigate to the Quest Features window.
Ensure that Scene Support is enabled.
In Permission Requests On Startup, check the Scene option.
The app will try to request the permission on app startup if it has not already been granted.
If the permission has not been granted by the user:
OVRSceneAnchor and the OVRSceneRoom objects will not be available.
If you are using OVRSceneManager.LoadSceneModel(), it will result in an OVRSceneManager.NoSceneModelToLoad event, even if there is spatial data captured on the device.
If you are using OVRSceneModelLoader, it will result in OVRSceneModelLoader.OnNoSceneModelToLoad() callback, which will run Space Setup.
This option does not provide access to permission callbacks, and may prevent a separate permission request with callbacks from completing successfully.Using the Scene Model
Unity
All-In-One VR
The platform for which this article is written (Unity) does not match your preferred platform (Nativa).
Haz clic aquí para ver la página del índice de la documentación para tu plataforma de preferencia.
In this page you will learn more about how the Scene Model is implemented, how it is captured through Space Setup, and how Scene Anchors provide access to the real world environment data.
How does the Scene Model and Space Setup work?
The Scene Model is composed of a number of Scene Anchors, each of which hold on to some further data describing their intent. The anchor framework is closely related to the Entity-Component-System pattern, whereby an Entity is little more than a storable data type with a unique identifier, Components contain data and are stored on Entities, and Systems operate globally on all Entities that have the necessary Components. In the context of the Scene Model, a Scene Anchor is an Entity, and can have any number of Components on it (such as semantic classification, 2D bounding box, locatable).
Space Setup (formerly known as Scene Capture) is the process which captures a Scene Model. It is managed by the system so that all apps running on a device have access to the same environment data, which is starkly in contrast to the paradigm where every app would need to scan the environment during the app’s lifecycle. Space Setup is a user-guided process: it first scans the environment to obtain a space mesh and to extract the space information (such as floor and ceiling height, walls, objects), and then the user completes the process by correcting any errors (wall positioning) and adding missing information (room objects). The process can be invoked by the system or by an app.
You currently cannot perform Space Setup over Meta Quest Link. You must perform Space Setup on-device prior to loading the Scene Model over Link.
The Scene Model contains sensitive user data and is thus fully controlled by the user for whether an app can access the data or not. Apps must declare their intention of using the permission through the app’s manifest file, and then perform a permission request at runtime to prompt the user for approval.
What components can Scene Anchors have?
Scene Anchors require components in order for them to describe the environment represented by the Scene Model. In order for a component to provide data, it has to be enabled. Apps must therefore query both if an Scene Anchor supports a given component, and if the component has been enabled.
As Scene Anchors can only be created through the Space Setup process, we call these types of anchors system-managed, while Spatial Anchors are user-managed.
Spatial Anchors and Scene Anchors Are Different
There are a few differences between spatial and scene anchors. Scene anchors are created by the boundary, while spatial anchors are created by your application. Scene anchors contain other information specific to the scene, such as the anchor's pose. And finally your app can create spatial anchors only, but it can query scene anchors.
A Locatable component informs the system that this anchor can be tracked. Once enabled, an app can continually query the pose information of the anchor, which can vary due to a difference in tracking accuracy over an anchor’s life.
A RoomLayout component contains references to anchors that make up the walls, the ceiling and the floor. An AnchorContainer component contains a reference to a list of child anchors.
The Bounded2D and Bounded3D components provide information about the dimensions of an anchor. They have a size property which captures the dimensions, and an offset property which describes the difference between the origin of the 2D/3D bounding box and the anchor’s origin defined by the Locatable component. The TriangleMesh component provides an indexed triangle mesh for an anchor.