I want to create spatial anchors as use them IDs. I want to use these IDs as inpiut in another app to position multiple set of objects. Whenever I open this App, it should locatet the designated objects by looking for the assigned IDs as locations of the objects. I read the spatial anchor documentation in unity and I have following questions.
What I found in the documentation and example, that I can create spatial anchors using the given example unity project, but i dont understnad if those anchors created by the example project are saved in ML permanently and can be accessed or used by another applicaiton? if so how can we do it?
Is bulilding the Unity example project the only way to assign spatial anchors or there are other ways. In my case, I just need to design a workflow where I dont need to take care of setting up the anchors when I open my final app and designated objects get localised on its own by presaved anchors.
I could only find example and documentation for Unity, is this feature not well supported on Unreal, if so where can I find its doc and example project?
Anchors created by the Unity and Unreal example project are created and can be "published" which saves the anchors to the space. They can later be queried using the Spatial Anchor Storage API. You can also visualize the saved anchors inside the Spaces app , by selecting the 3 dots next to the space and selecting View. A think white line will point to the origin of each anchor.
No, you can create spatial anchors inside Unreal and Unity. Please see the Unreal Example project for more information
I recommend using the tool that you are most familiar with.
Note, before using anchors you will need to map the spaces inside the Spaces app. Anchors can only be published to the map when you are localized (when the headset recognizes the environment you are in)
You can publish anchors in one app and query the anchors in another. The anchor query will return all of the anchors that are published.
Also when I try to build the app on ML2, I get the following prompt:
PlayerSettings->Active Input Handling is set to Both, this is unsupported on Android and might cause issues with input and application performance. Please choose only one active input handling. Ignore and continue? (This dialog won't appear again in this Editor session if you'll choose Yes)"
I have doubts on the unity version and Magicleap SDK version requirements and if I should build it through MagicLeap provider or OpenXR provider. Problem persists on both latest Unity and 2022.2.0f1 for which the example project was built.
When you open the Space app, do you see a purple pin next to the name of the Space?
When you opened the project in 2022.2.0f1, was this after you tried to open it in a newer Unity version?
I would recommend using the Magic Leap 2 Unity Examples project, which shows how to use the latest SDK to query anchor positions. Additionally, if you are new to the field you can do the following:
Scan the Space and Download the Mesh:
Scan the environment using the Spaces application. Take your time to make sure the space is scanned well.
Once the space is saved, export the mesh into the downloads folder
Attach your device to your computer and download the mesh from the Magic Leap 2 using the Magic Leap Hub 3
Drag and Drop this mesh into the latest version of the Unity Examples Project
Download the GLTF Fast Package:
Open the Package Manager in Unity
Select the Plus Icon and select Add by name...
Input the following name com.unity.cloud.gltfast and then select Install.
Unity will load a little before the package is installed.
Add the Mesh to your scene:
Once the package is installed, the GLB file inside Unity can be viewed as a Mesh.
Drag and drop it into your scene. (You can choose any scene, including the spatial anchor scene.)
The mesh will appear lightly red, you can change the material on the Mesh's Mesh Renderer if you like.
Align the mesh with the space origin:
Add the the following script into your project. MapOriginTest.cs (1.9 KB)
Attach it to am Empty Game Object and then assign the rootTransform parameter in the inspector to reference the exported Space.
The map will shift to match the space Origin when the app is deployed to the device.
Add objects:
You can add additional virtual objects as children of the space origin.
If you need to make modifications or changes, feel free to edit the script and check out the Localization Map section of the developer portal.
Important:
The space origin is a quick way to align objects in an environment. However, you unlike Spatial anchors, the origin cannot be changed once the space is created. This can lead to the origin being less accurate than a Spatial Anchor.