This page describes the older Shared Scene implementation. The current Unity-SharedSpatialAnchors project does not contain Assets/SceneSharing/Scenes/SharedSpatialAnchorsWithScene.unity. For the maintained user-sharing and group-sharing scenes, see Shared Spatial Anchors Sample.
Unity-SharedSpatialAnchors Scene Sharing was built to demonstrate how to use the Shared Spatial Anchors API, available in the Meta XR Core SDK for the Unity game engine. The sample app showcases the creation, saving, loading, and sharing of Spatial Anchors, and the sharing of scene objects (walls, floors, desks, tables, and so on).
For anchor and scene sharing, this app uses Photon Unity Networking to share player data, and also allows users to interact with networked objects in a co-located space.
This codebase is available both as a reference and as a template for a game that utilizes Shared Spatial Anchors. The project is under the Unity-SharedSpatialAnchors license unless otherwise specified.
The older scene was located at Assets/SceneSharing/Scenes/SharedSpatialAnchorsWithScene.unity. The hierarchy and scripts below describe that implementation, rather than current sample setup.
Scene Hierarchy
ControlPanel - World-space UI for creating/loading anchors and spawning cubes
PhotonNetworkManager - Networking Manager for Photon rooms, player synchronization, and shared anchor ID sharing.
OVRCameraRig - The tracking space with OVR camera and hand components as children
SceneCaptureController - Manages API calls and callbacks for the Scene API
WorldGenerationController - Controls object and mesh creation for scene objects
Prefabs
SpatialAnchorPlacement: Placement prefab for anchor placement visualization
SpatialAnchorPrefab:
SharedAnchor: Interface for anchor alignment and sharing
OVRSpatialAnchor: SDK script that controls orientation of the anchor after localization.
PhotonGrabbableObject: Manages the transfer of ownership for the networked cube
PhotonThrowableObject: Manages the transfer of ownership for the networked cube
Scripts/Components
SharedAnchorLoader: Manages API calls and callbacks for the SSA API
SceneApiSceneCaptureStrategy: Manages API calls and callbacks for the Scene API
Scene: Serialized object for storing and sharing scene data (Walls, Desks, Floor, and so on)