Meshing broken in latest dev2 updates

@jc1 Can you try removing any custom scripts that enable meshing and try to do the following:

1.Create Mesh Root

  1. Create a new GameObject and name it "Mesh Root"
  2. Make sure that it is positioned at 0,0,0 and has the scale set to 1,1,1

2.Create Mesh Graphic

  1. 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
  2. Add a Mesh Collider (if you are using collisions)
  3. Add a Mesh filter
  4. Drag it into your assets folder to create a prefab

2.Configure the Meshing Subsystem Component

  1. Next, Create a new GameObject and name it "Meshing Subsystem"
  2. Add the Meshing Subsystem Component to the "Meshing Subsystem" GameObject
  3. Set the scale of the "Meshing Subsystem" to 10,10,10
  4. Then Set the Mesh Parent to the Mesh Root GameObject
  5. Set the Mesh Prefab to the Mesh prefab that you created in the previous step

3.Permissions

  1. After the components are configured, make sure you have enabled Spatial Mapping in the Permission Settings.
  2. 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"
  3. Add it to the Mesh Root GameObject
  4. 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;
    }
}

1 Like