# Persistence

Make Any AR Object Persistent



# About this Sample

This sample showcases how to leverage AR Persistence to create a seamless and persistent augmented reality experience in your application. With AR Persistence, virtual objects can be anchored to real-world locations and persist across multiple sessions, allowing users to revisit and interact with them exactly where they left them, even after closing the application.

This capability opens up new possibilities for creating immersive and engaging AR applications, where users can easily place virtual objects in the real world and revisit them later. Upon completing this sample, you will have a fully functional AR scene that leverages AR Persistence to create a dynamic and interactive environment. To start working with this sample, you need to install Resight Engine.

# Follow these steps after setting up Resight Engine:

  1. Go to the Resight Samples / Persistence AR Sample folder
  2. Locate the scene named “Persistence AR” and open it

# Persistence AR Scene

The AR setup is complete and features an AR Session to oversee the AR experience, as well as an AR Session Origin, which contains the Main Camera, The AR Plane Manager, and the AR Raycast Manager. The scene is also equipped with Resight Engine.

# Resight Engine Settings

  1. Go to the 'Resight' game object in the open scene
  2. Find the 'LibResight' component
  3. Enter your developer key (provided by Resight) and a namespace

    • A namespace can be any string (without spaces), for example: Default / Production / Test-1
    • A namespace is a unique data store under your developer account
    • Mapping data and snapped objects are not shared between different namespaces

# Mesh Manager

  1. Go to the 'Resight' game object in the open scene
  2. Find the 'Mesh Manager' component

# Physics:

You have the option to disable the collider. This can be useful when you don't want objects to collide with the mesh.

# Rendering:

  1. Select a pre-made shader/material for your mesh. This can save you time and effort as you can choose from a range of pre-existing options rather than creating your own from scratch.
  2. Add your own custom shader/material.

# AR Occlusion Manager

The AR Occlusion Manager provides real-time occlusion of virtual objects in AR scenes. Occlusion refers to the effect of blocking the view of one object by another, as occurs when one object is placed in front of another in the real world. In case you don't add AR Occlusion Manager and you have Mesh Manager in the scene, Resight Engine will use a default AR Occlusion Manager.

# Entities Manager

The Entities Manager component stores the position and orientation of virtual objects, ensuring that they remain anchored in the correct location.

# Snapped Object

  1. Go to the 'Prefabs' folder in your project
  2. Double-click on one of the Prefabs, 'Ground' or 'Tree'
  3. Look for the 'SnappedObject' script attached to the object

The 'SnappedObject' script provides persistence for objects by allowing them to be placed in the world and "stick" to the physical environment. Once you attach this script to your Prefabs, the objects will remain in place and stable, even when switching between sessions or closing and reopening the application. If you want to rename an object, make sure to add the script again to ensure that the object remains persistent.

NOTICE: Persistent objects should be placed in the "Resources" folder.

# Game Manager

The MeshPlacement script utilizes Physics's Raycast functions to facilitate the real-world placement of objects. If desired, you have the option to personalize the scene by substituting the default objects with your own Prefabs.

  1. Find the Game Manager object in the Hierarchy
  2. Drag and drop your own Prefab to Placed Prefab:

    This scene utilizes the movement scripts to facilitate effortless manipulation and removal of objects in collaboration with our live mesh.

    The scene comes with pre-made materials, 3D models, and Prefabs that are ready for your use without any restrictions. Enjoy! 🙃