⚠ Preview docs — built from the develop branch and may be unstable. Go to the stable docs.

SpatialEntity.Status

SpatialStatus Status{ get }

Description

Whether the things you’ve asked of this entity have gone through, like creating, loading, or persisting it. Ready means all done, Pending means something’s still in progress, and negative values are failures: Partial if a request like Persist failed, Failed if the entity couldn’t be created or found at all. This is separate from Tracked, so a Pending anchor can still be tracked and usable.

Examples

Keeping track of anchors by Guid

For apps that keep anchors in their own save data instead of by name. The Guid arrives a moment after Persist, so watch for it.

List<Guid> savedAnchors = new List<Guid>();

public void StepSavedAnchors()
{
	foreach (SpatialEntity anchor in SpatialEntity.With(SpatialComponent.Anchor))
	{
		if (anchor.HasChanged(SpatialComponent.Persistence) && anchor.TryGetGuid(out Guid guid))
			savedAnchors.Add(guid);
	}

	// Storage no longer having a Guid shows up as Failed
	foreach (SpatialEntity anchor in SpatialEntity.Removed)
	{
		if (anchor.Status == SpatialStatus.Failed && anchor.TryGetGuid(out Guid lost))
			savedAnchors.Remove(lost);
	}
}

// In a later session, each Guid loads back into its anchor
public List<SpatialEntity> RestoreAnchors()
{
	List<SpatialEntity> result = new List<SpatialEntity>();
	foreach (Guid guid in savedAnchors)
		result.Add(SpatialEntity.FindAnchor(guid));
	return result;
}




Found an issue with these docs, or have some additional questions? Create an Issue on Github!