@jc1 Can you try removing any custom scripts that enable meshing and try to do the following:
1.Create Mesh Root
- Create a new GameObject and name it "Mesh Root"
- Make sure that it is positioned at 0,0,0 and has the scale set to 1,1,1
2.Create Mesh Graphic
- Create an empty game object and name it "Mesh"
2.Add A mesh Renderer Component to it
3.Create a new material and assign it under the Materials Tab - Add a Mesh Collider (if you are using collisions)
- Add a Mesh filter
- Drag it into your assets folder to create a prefab
2.Configure the Meshing Subsystem Component
- Next, Create a new GameObject and name it "Meshing Subsystem"
- Add the Meshing Subsystem Component to the "Meshing Subsystem" GameObject
- Set the scale of the "Meshing Subsystem" to 10,10,10
- Then Set the Mesh Parent to the Mesh Root GameObject
- Set the Mesh Prefab to the Mesh prefab that you created in the previous step
3.Permissions
- After the components are configured, make sure you have enabled Spatial Mapping in the Permission Settings.
- Since this is a dangerous permission, you will need to request it at runtime. To do this create a new script and name it something like "MeshingPermissionRequester"
- Add it to the Mesh Root GameObject
- Open the script and add the following line of code
using UnityEngine;
using UnityEngine.XR.MagicLeap;
public class MeshingPermissionRequester : MonoBehaviour
{
private MeshingSubsystemComponent _meshManager;
private readonly MLPermissions.Callbacks _permissionCallbacks = new MLPermissions.Callbacks();
private void Awake()
{
_permissionCallbacks.OnPermissionGranted += OnPermissionGranted;
_permissionCallbacks.OnPermissionDenied += OnPermissionDenied;
}
private void OnDestroy()
{
_permissionCallbacks.OnPermissionGranted -= OnPermissionGranted;
_permissionCallbacks.OnPermissionDenied -= OnPermissionDenied;
}
private void Start()
{
_meshManager = FindObjectOfType<MeshingSubsystemComponent>();
if (_meshManager == null)
{
Debug.LogError("Failed to find MeshingSubsystemComponent in scene. Disabling Script");
enabled = false;
}
else
{
_meshManager.enabled = false;
}
MLPermissions.RequestPermission(MLPermission.SpatialMapping, _permissionCallbacks);
}
private void OnPermissionGranted(string permission)
{
_meshManager.enabled = true;
}
private void OnPermissionDenied(string permission)
{
Debug.LogError($"Failed to create Mesh Subsystem due to missing or denied {MLPermission.SpatialMapping} permission. Please add to manifest. Disabling script.");
enabled = false;
}
}