text
stringlengths
0
1.11k
The Unity objects contain a reference to a OVRAnchor from a previous snapshot. This is updated by finding OVRAnchor pairs between the snapshots.
Similar to the Snapshot Scene Manager, the Dynamic Scene Manager assumes a dynamic Scene Model. It also provides an important optimization over the OVRSceneManager by updating content, instead of respawning all content.
Key Assets
OVRCameraRig Game Object | .\Assets\Oculus\VR\Prefabs | Provides a VR/MR-ready camera and configures the device using the OVRManager component.
Basic Scene Manager Script | .\Assets\StarterSamples\Usage\SceneManager\Scripts\CustomSceneManager | This script creates Unity primitives for all elements of the Scene.
Prefab Scene Manager Script | .\Assets\StarterSamples\Usage\SceneManager\Scripts\CustomSceneManager | This script instantiates user-provided prefabs for certain elements of the Scene.
Snapshot Scene Manager Script | .\Assets\StarterSamples\Usage\SceneManager\Scripts\CustomSceneManager | This script will poll the Scene data, save snapshots at each poll, and log any changes to the console.
Scene Manager Helper Script | .\Assets\StarterSamples\Usage\SceneManager\Scripts\CustomSceneManager | This helper script is used by the other Scene Manager scripts to share common code.
Dynamic Scene Manager Script | .\Assets\StarterSamples\Usage\SceneManager\Scripts\CustomSceneManager | This script extends the Snapshot Scene Manager by maintaining a link of Unity game objects for Scene data snapshots to allow updates.
Dynamic Scene Manager Helper Script | .\Assets\StarterSamples\Usage\SceneManager\Scripts\CustomSceneManager | This helper script is used by the Dynamic Scene Manager to help the legibility of the core functionality.Spatial Anchors Overview
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.
Health & Safety Recommendation
While building mixed reality experiences, we highly recommend evaluating your content to offer your users a comfortable and safe experience. Please refer to the Health and Safety and Mixed Reality Design guidelines before designing and developing your app.
Co-location increases the number of individuals in a shared physical space with restricted visibility of their surroundings. Crowded experiences create safety risks. It is important to be mindful of the occupancy of the playspace for the shared experience being built. For more information, see Shared Spatial Anchors health and safety guidelines. Additionally, a sample developer app with health and safety suggestions is available for easy integration.
Spatial anchors are world-locked frames of reference you can use to position content. They are transforms that represent fixed physical locations in the real world.
You can use spatial anchors to enrich the user experience in many ways, such as placing virtual signs on real furniture, or creating spawn points on real windows for virtual characters to fly through.
Samples
Spatial Anchors Sample illustrates use of the Spatial Anchors API.
Shared Anchors Sample shows how to use both local and shared anchors.
Creating a New Spatial Anchor
Spatial Anchors are Most Effective within 3 Meters
Create a spatial anchor within 3m of the object you want to anchor. Otherwise, your pose will be incorrect due to drift (that is, even though the location of the spatial anchor remains the same, the farther the user moves away from the spatial anchor, the greater the drift of the objects attached to the spatial anchor will seem to that user). If you attach content to a nearby anchor (within 3m), it will remain in place relative to the anchor, even if the user goes farther away than 3m.
A spatial anchor is a world-locked frame of reference. It represents a fixed position and orientation in the real world. You create a spatial anchor at a specific 6DOF pose and then use it to drive the transform of your virtual content.
You create spatial anchors using the Unity method GameObject.AddComponent<OVRSpatialAnchor>().
Spatial Anchor Storage Targets
Saving a spatial anchor can involve two different storage target types.
Local Storage The spatial anchor object is stored directly in the user’s headset, and persists through sessions. This provides the app quick access to spatial anchors.
Cloud Storage If the user has authorized cloud access, the spatial anchor object is stored in a cloud location associated with the user’s account. You do this in preparation for sharing the spatial anchors among a group of users. For more information, see Shared Spatial Anchors.
Note that once you have saved a spatial anchor in local or cloud storage, you need its UUID to load it. You must save the spatial anchor UUID to a separate location to refer to its anchor in a future session. In Unity, you can use PlayerPrefs for this purpose. we provide an example of this in Save Spatial Anchor UUIDs to PlayerPrefs
Destroy a Spatial Anchor
Once you create a spatial anchor, you can destroy it using the Unity engine method Destroy().
When you destroy a spatial anchor, you remove the spatial anchor from the user’s experience. Any virtual object that was using the spatial anchor remains, though its transforms will no longer be driven by the spatial anchor, so it is no longer locked to its previous real-world location.
Destroying a spatial anchor does not remove the spatial anchor from local or cloud storage. If you no longer need the anchor, you should also Erase it from all storage.
Save a Spatial Anchor Locally or to the Cloud
You can save a spatial anchor object locally or to the cloud using the OVRSpatialAnchor.Save() method, using the OVRSpace.StorageLocation enum.
Note that you only ever need to store spatial anchors to the cloud if you need to the share the anchors to another user. Otherwise, the parameter is optional and defaults to local storage for loading the anchor at a later stage.
Save Spatial Anchor UUIDs to External Storage
The OVRSpatialAnchor.Save() method saves the entire spatial anchor object to local or cloud storage. To load it back into the user’s experience, you need its UUID. You can track the UUIDs during runtime, but if you want to make it easy to manage saved spatial anchors in future sessions, you need to save them to an external storage location.
In the StarterSamples Spatial Anchors sample, we make use of Unity PlayerPrefs to persist the spatial anchor UUIDs. The UUIDs are later used as one parameter to the OVRSpatialAnchor.LoadUnboundAnchors() method.
Load a Saved Spatial Anchor
If you want to be able to bring a saved spatial anchor back into the user’s experience, you can load it as long as you have saved it to local or cloud storage first. If you are tracking the spatial anchor UUIDs during runtime, you can quickly load the anchor using its UUID. With the spatial anchor UUID, you load the anchor (as an unbound anchor). localize it, and bind it to a game object’s OVRSpatialAnchor object. See Load a Spatial Anchor from the Headset or the Cloud for more information.
Erase a Spatial Anchor from Local or Cloud Storage
A spatial anchor can be erased from local or cloud storage. This does not affect its existence in the user’s experience, but it means the spatial anchor will not be available in future sessions unless you save it again before the session ends. You use the OVRSpatialAnchor.Erase() method to erase a spatial anchor.
Samples and Showcase Apps
To quickly build a sample that uses spatial anchors, check out the Spatial Anchors sample in the Starter Samples.
Also, you can find more examples of using spatial anchors with Meta Quest in the oculus-samples GitHub repository. The Unity-Discover and Unity-SharedSpatialAnchors apps both highlight the implementation of spatial anchors.Use Spatial Anchors
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.
Spatial anchors enable you to provide users with an environment that is consistent and familiar. Users expect objects they place or encounter to be in the same location the next time they enter the scene.
OVRSpatialAnchor Component
In your code, you use the OVRSpatialAnchor() component to place objects in your scenes. With this API, you can: