private void HandleObjectAnchorsServiceEvent() { Func <IObjectAnchorsServiceEventArgs, string> EventArgsFormatter = args => { return($"[{args.LastUpdatedTime.ToLongTimeString()}] ${TextLogger.Truncate(args.InstanceId.ToString(), 5)}"); }; ObjectAnchorsServiceEvent _event; while (_objectAnchorsEventQueue.TryDequeue(out _event)) { switch (_event.Kind) { case ObjectAnchorsServiceEventKind.DetectionAttempted: { TextLogger.Log($"detection attempted"); break; } case ObjectAnchorsServiceEventKind.Added: { TextLogger.LogRaw($"{EventArgsFormatter(_event.Args)} found, coverage {_event.Args.SurfaceCoverage.ToString("0.00")}"); DrawBoundingBox(_event.Args); break; } case ObjectAnchorsServiceEventKind.Updated: { TextLogger.LogRaw($"{EventArgsFormatter(_event.Args)} updated, coverage {_event.Args.SurfaceCoverage.ToString("0.00")}"); DrawBoundingBox(_event.Args); break; } case ObjectAnchorsServiceEventKind.Removed: { TextLogger.LogRaw($"{EventArgsFormatter(_event.Args)} removed"); var bbox = _boundingBoxes[_event.Args.InstanceId]; _boundingBoxes.Remove(_event.Args.InstanceId); bbox.gameObject.SetActive(false); DestroyImmediate(bbox); break; } } } }