Skip to main content
Version: 12 Dec 2024

Meshing Query Location Example

This section includes an example on how to change the bounds and origin of mesh queries that are generated by the UnityEngine.XR.MagicLeap.MeshingSubsystemComponent. This feature is useful to limit the amount of meshes generated at runtime to reduce performance overhead meshes

caution

Before proceeding make sure you have an object with a properly configured MeshingSubsystemComponent attached. In addition to having the SPATIAL_MAPPING permission to be enabled in your project's Manifest Settings. (Edit > Project Settings > Magic Leap > Manifest Settings)

Example

This example adjusts the location of the mesh queries to originate from the Main Camera and the size of it's bounds.

using UnityEngine;
using UnityEngine.XR.MagicLeap;

public class MeshQueryLocationExample : MonoBehaviour
{
[SerializeField, Tooltip("The spatial mapper from which to update mesh params.")]
private MeshingSubsystemComponent _meshingSubsystemComponent = null;
[SerializeField, Tooltip("The Bounds to query for meshes in meters.")]
private Vector3 _bounds = new Vector3(5,5,5);

void Update()
{
_meshingSubsystemComponent.gameObject.transform.position = Camera.main.gameObject.transform.position;
_meshingSubsystemComponent.gameObject.transform.localScale = _bounds;
}

}