text
stringlengths
0
1.11k
SSA Showcase Apps and Walkthrough
Two showcase applications are available that highlight the use of SSAs. Both are available in the oculus-samples GitHub repository. Both of these applications use Photon Unity Networking to share player data.
The Unity-SharedSpatialAnchors showcase app is an established application which highlight the implementation of shared spatial anchors, and allows users to interact with networked objects in a co-located space. The page Shared Spatial Anchors Sample provides documentation on how to build and use the sample.
The Unity-Discover showcase app is a newer application which has fewer features, and which demonstrates how to use a single SSA effectively in a multipurpose application. To help you understand how the SSA is implemented, check out the Shared Spatial Anchors (SSA) WalkthroughSpatial Anchors Basic Tutorial
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 are world-locked frames of reference you can use in your app to place and orient objects that will persist between sessions. This consistency provides users with a sense of continuation and familiarity each time they reenter your game or app.
As it details in Use Spatial Anchors, the key element to successfully placing a spatial anchor is the OVRSpatialAnchor component. In this tutorial, you assemble a project similar to the Starter Samples Spatial Anchors Sample, but with many fewer features. Here’s what you do in this tutorial:
Create a scene that includes the OVRManager and OVRPassthroughlayer.
Create two prefab capsules, one for the LeftControllerAnchor, and one for the RightControllerAnchor. These always display at the controller.
Create two placement prefabs, one for each controller. These also contain capsules, but these capsules only show when you create them and anchor them in space.
Create a minimal script that governs how spatial anchors are created, destroyed, loaded, and erased.
Create a GameObject to connect the spatial anchor management code with the capsule and transform prefabs.
Add the script to the GameObject, and assign the capsules and transforms to the script’s public members.
See Try Out the App at the end of this topic to read how the app works.
Before You Begin
You should first do the Basic Passthrough Tutorial. Once you complete that, you will be ready to do this basic Spatial Anchors tutorial.
Create a New Scene
In the Project tab, under the Assets folder, create a new folder named SpatialAnchors Tutorial. Then select it to make it the current folder for new objects.
In the Project Hierarchy, right click SampleScene, and choose Save Scene As. Give the new scene a unique name, such as SpatialAnchorsTutorial. This becomes the active scene in the Hierarchy.
Remove any game objects from the scene, except for the Directional Light and OVRCameraRig.
Set up the Major Scene Components
The OVRCameraRig, OVRSceneManager, and OVRPassthroughLayer are all components that you need to set up the scene.
Set up the OVRCameraRig and OVRManager
The OVRCameraRig is the main camera for your scene. Set it up as follows. These are typical settings for a passthrough scene.
If you haven’t done so already, select the Main Camera and press the Delete key to remove it from the scene.
If you haven’t done so already, in the Project pane, search for the OVRCameraRig prefab. Drag it to the SpatialAnchorsTutorial scene. Then select it to show its properties in the Inspector.
On the Inspector tab, do the following:
Under OVRManager, set Tracking Origin Type to Eye Level.
Under OVRManager, go to Quest Features > General.
From the Anchor Support dropdown, select Enabled to turn on anchor support.
Under Insight Passthrough, check the Enable Passthrough checkbox.
Set up the OVRCameraRigSet up the OVRCameraRig
Set up the OVRPassthroughLayer
Adding the OVRPassthroughLayer enables the ball to bounce off of objects in your environment.
In the Hierarchy pane, select the OVRCameraRig game object.
At the bottom of the Inspector, choose Add Component. Search for and select OVR Passthrough Layer.
Expand the OVR Passthrough Layer component. Set Projection Surface to Reconstructed and Placement to Underlay
Set Up the OVRPassthroughLayer
Create the Green and Red Prefab Controller Capsules
Create the green and red capsule prefabs that will float near each controller. These capsules will indicate where the smaller anchor capsules will be created.
In the Project tab, select the SpatialAnchors Tutorial folder to make it the current folder for new objects.
From the Assets menu, select Create > Prefab. Name the new prefab SaveablePrefab. Double-click the new prefab to edit it.
In the Inspector, add the following values to the Transform component.
Set the Position property to X = -0.2, Y = 1.03, and Z = 0.
Set the Rotation property to X = 0, Y = 0, and Z = 0.
Set the Scale property to X = 0.1, Y = 0.1, and Z = 0.1.
In the Hiearachy, right click the SaveablePrefab object, and then choose 3D Object > Capsule. Make sure the new capsule is a child of the SaveablePrefab object.
In the Hierarchy, select the new capsule.
In the Project pane, search for the Green material. Drag the material into the SpatialAnchors Tutorial Assets folder.
In the Inspector, in the Materials property, choose the Green material.
New SATutorialSceneNew SATutorialScene
Repeat the previous steps, creating a prefab named NonSaveablePrefab, with these changes:
Instead of a position X value of -0.2, set the Position property to X = 2.0.
For this prefab, instead of the Green material, choose the Red material.
Create the Saveable and NonSaveable Placement Prefabs
Separate placement prefabs are needed for each controller. These prefabs contain capsules that are created when you press the controller index trigger.
Create the SaveablePlacement Prefab
In the Project tab, select the SpatialAnchors Tutorial folder to make it the current folder for new objects.
From the Assets menu, select Create > Prefab. Name the new prefab SaveablePlacement.
Double-click the SaveablePlacement to edit it.
In the Inspector, add the following values to the SaveablePlacement Transform component.
Set the Position property to X = 0.0, Y = 0.0, and Z = 0.25.
Set the Rotation property to X = 0, Y = 0, and Z = 0.
Set the Scale property to X = 0.025, Y = 0.025, and Z = 0.025.
In the Hiearachy, right-click the SaveablePlacement object, and then choose Create Empty.
Make sure the new object is a child of the SaveablePlacement object, and then name it SaveableTransform.
In the Inspector, add the following values to the SaveableTransform Transform component.
Set the Position property to X = 0.0, Y = 0.1, and Z = 0.1.
Set the Rotation property to X = 0, Y = 0, and Z = 0.
Set the Scale property to X = 0.025, Y = 0.025, and Z = 0.025.
In the Hiearachy, right click the SaveablePlacement object again, and then choose 3D Object > Capsule. Make sure the new capsule is a child of the SaveablePlacement object.
In the Hierarchy, select the new capsule.
In the Inspector, add the following values to the Capsule Transform component.
Set the Position property to X = 0, Y = 0, and Z = 0.125