Unity-Technologies / arfoundation-samples

Example content for Unity projects based on AR Foundation
Other
3.04k stars 1.14k forks source link

XR Simulation: requestedDetectionMode not working #1120

Closed micsanbr closed 7 months ago

micsanbr commented 10 months ago
  1. Create an empty scene
  2. Add "AR Session"
  3. Add "XR Origin (Mobile AR)"
  4. Select "XR Origin (Mobile AR)"
  5. Add a "AR Plane Manager" to the XR Origin
  6. Create a new AR Default Plane into the scene, turn it into a Prefab and delete the reference from the scene
  7. Assign the AR Default Plane prefab to the Plane Prefab of the AR Plane Manager
  8. Set the Detection mode of the AR Plane Manager to Horizontal only (disable Vertical)
  9. Test using the XR Simulation package directly in the editor.

Expected behavior It should detect only horizontal planes.

Actual behavior It detects both planes.

Additional note: The UI still uses detectionMode which gets a warning saying it's obsolete. https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@5.1/manual/features/plane-detection.html Setting / getting RequestedDetectionMode and currentDetectionMode (readonly) don't seem to do anything. https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@5.1/api/UnityEngine.XR.ARFoundation.ARPlaneManager.html Pretty confusing.

Workaround

void OnPlanesChanged(ARPlanesChangedEventArgs args) {
        foreach (ARPlane plane in args.added)
        {
            // Check whether the plane is a vertical plane and disable it
            if (plane.alignment == PlaneAlignment.Vertical)
            {
                plane.gameObject.SetActive(false);
            }
        }

// ... other stuff
}
andyb-unity commented 10 months ago

Thanks @micsanbr. We've confirmed this issue on our end and filed a bug for a future fix. We'll update this issue when that work is assigned to a developer and a fix is merged in.

andyb-unity commented 8 months ago

This will be fixed in the 5.1.2 release.

ankur-unity commented 7 months ago

Fixed in 5.1.2. Feel free to open another issue if you have further concerns. https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@5.1/changelog/CHANGELOG.html#fixed