The Content Placement Sample
This simple scene shows how to store AR objects on the device locally for persistent AR experiences.
This sample requires you to first map a location with the Mapping App
Open the ContentPlacementSample scene found in the Assets/ImmersalSDK/Samples/Scenes
folder.
Downloading Your Map
Log in to the Developer Portal and download your map file of a pre-mapped location.
Overview of the scene
The scene is similar to the Mapping App but has a few more game objects.

AR Session, AR Session Origin and AR Camera
Game objects provided by AR Foundation and you can find more about their functionalities from Unity's documentation. They provide the basic functionalities for the AR session.
ImmersalSDK
Basic settings for our SDK and the ARLocalizer.cs
script.

Developer Token is where you would insert your token found in our Developer Portal. In this sample the token is not needed since there is a separate login process.
Target Frame Rate for the app. iOS can manage 60fps, but most Android devices are locked to 30fps
Android Resolution specifies the image size used by our SDK computer vision. Some older Android devices have performance issues with bigger image sizes so you can change this if needed. For mapping it is best to leave this value at Max for best results even if the UI feels sluggish.
iOS Resolution is the same setting, but for iOS devices. You can leave this at default, which for most devices is the maximum resolution.
Downsample downsamples image to HD resolution.
OnPoseLost unity event that is called when the localization pose is lost.
OnPoseFound unity event that is called when the localization pose is found.
Seconds To Decay Pose a timer to decrease pose results.
AR Localizer is the script that uses our SDK to find the device pose within the map.
Autostart makes the localizer to start to try to localize at scene startup.
Localization Interval sets the interval between attempted localizations.
Use Filtering when enabled uses AVT Statistical filtering on poses.
Reset On Map Change reset localizer filtering when relocalized against a different map than the previous time
Burst Mode at the app start, burst mode will try to find the first ten or so poses as fast as possible.
Use Geo Pose Localiser use the on-server GeoPose localizer.
Use Server Localizer use the on-server localizer.
Map Id's optional server map IDs when the on-server localizer is used.
EventSystem and Canvas
These are components of Unity's UI system. The debug text displays the successful and total localization attempts.
The Pose Indicator is a prefab that gives an estimate of the current localization status. The prefab displays a red icon when no poses have been found or it has been a long time since the previous found pose. It also resets when AR Foundation loses tracking. When the SDK finds multiple poses, the indicator turns green.
The Pose Indicator also has events for OnPoseFound
and OnPoseLost
that can be used to trigger actions in an AR app.
ContentPlacementUI
A self-contained prefab that handles placing and storing AR objects in the scene. It is a simple implementation supporting copies of just one object to be instanced to the scene.
The prefab consists of the ContentStorageManager Game Object and buttons to add and delete the AR objects.


ContentStorageManager.cs
requires a reference to the AR Space game object under which the objects are instanced.
You can also specify the name for the .json
file that is stored on the device. The ContentStorageManager.cs
writes the prefab locations to the specified .json
file
AR Space and AR Map
These game objects are used by our SDK to transform the AR content to match the real-world.
When a pose is found by ARLocalizer.cs
, the AR Space is transformed in a way that the AR content visually matches the real-world. The AR Camera in the scene is not transformed, but the AR Space is brought to the camera.
Technically the content can be placed under the AR Maps themselves if that makes organizing the scene easier.
Map files in AR Maps are used to move the parent AR Space object. Every AR Map needs to have a parent AR Space object. If one does not exist, it will be created at runtime.
Since this sample uses an embedded map file, you should place the previously downloaded map to the Map File slot.

Point Size let's you change the point cloud size in the scene.
Render as 3D Points renders points as 3D.
Render Mode sets the visibility of the preview point cloud. You can disable or render it in Editor and/or at runtime.
Map File is where you place your
.bytes
map data files available from the Developer Portal.Color changes the color of the preview point cloud.
Map Metadata shows the metadata tied to the specific map.
On First Localization event is fired when the specific ARMap is localized.
Alignment metadata Load Alignment - Loads the ARMap alignment in conjunction to the ARSpace it is located at from metadata. Save Alignment - Saves the ARMap aligment in conjunction to the ARSpace. Reset Alignment - Sets the map metadata alignment to zero in conjunction to the ARSpace.
Using the Sample
Place your downloaded map file into the AR Map game object's map file slot in the inspector.
Open Build Settings (Ctrl + Shift + B) and make sure only the ContentPlacementSample is included in the Scenes in Build.
Change your Player Settings if necessary. It's a good idea to change the Product Name and Package Name so the app will not overwrite a previously installed app on your device.
Build the app and install it to your device.
When you start the app and look around at the location you mapped, the device should localize and find its pose in just seconds.
You can now add AR Diamond objects by clicking the Add Object button. You can delete all the objects by tapping on the Remove Objects button.
You can also move the AR Diamonds by dragging them on the screen. They have aMovableContent.cs
script for the additional functionality.
If you restart the app, any placed diamonds will remain in place and persist between app sessions.

Last updated
Was this helpful?