SpatialEntity.TryGetLabel
bool TryGetLabel(SpatialLabel& label)
A semantic category for this entity, like floor or
table. Not all devices provide labels, so check
Spatial.ComponentsFor for the capability you’re using. For planes,
TryGetPlaneAlign makes a good fallback.
| SpatialLabel& label | The entity’s semantic category, None if unavailable. |
| RETURNS: bool | False if this entity has no label component. |
Examples
Finding a table to put things on
Not every device labels its planes, so this falls back to any surface that faces upward.
static bool FindTable(out Pose surface)
{
foreach (SpatialEntity plane in SpatialEntity.With(SpatialComponent.Bounds2D))
{
bool isTable = plane.TryGetLabel(out SpatialLabel label)
? label == SpatialLabel.Table
: plane.TryGetPlaneAlign(out PlaneAlign align) && align == PlaneAlign.HorizontalUp;
if (isTable && plane.TryGetBounds2D(out surface, out _))
return true;
}
surface = Pose.Identity;
return false;
}
Found an issue with these docs, or have some additional questions? Create an Issue on Github!