Hello,
it seems that in [Unity 6.0.16f1 and newest AR Foundation] the ARPlane subsumedBy field is not set.
I am testing this with the XR Simulator. Could anybody confirm this?
I am trying to select an ARPlane, and when it gets subsumed, i want the newly merged ARPlane to be selected. For this I would want to look at newPlane = oldPlane.subsumedBy. This just never seems to be set. I’ve tried catching it in update, i’ve tried catching it OnTrackablesChanged of ARPlaneManager.
Here is some sample code:
private void OnTrackablesChanged(ARTrackablesChangedEventArgs<ARPlane> changes)
{
if (SelectedARPlane == null) return;
ReadOnlyList<KeyValuePair<TrackableId, ARPlane>> removedNow = changes.removed;
//V1
foreach (var removedPlane in removedNow)
{
// Compare the TrackableId of the removed plane with SelectedARPlane's TrackableId
if (removedPlane.Key == SelectedARPlane.trackableId)
{
Debug.Log($"Selected plane {SelectedARPlane.trackableId} has been removed.");
// ARPlane mergedPlane = SelectedARPlane.subsumedBy;
// Debug.Log($"It was subsumed by {mergedPlane.trackableId}");
// Handle the case where the selected plane has been removed
break;
}
}
//V2
if (SelectedARPlane.subsumedBy != null)
{
// Get the new merged plane and update the selection
ARPlane mergedPlane = SelectedARPlane.subsumedBy;
Debug.Log($"Selected plane {SelectedARPlane.trackableId} was subsumed by {mergedPlane.trackableId}");
// Select the new merged plane
Select(mergedPlane);
}
}
If anyone has any ideas, please let me know.
Kind regards,
Z