protected override SpongyAnchor CreateAnchor(AnchorId id, Transform parent, Pose initialPose) { SpongyAnchorXR spongyAnchorXR = null; if (IsTracking()) { DebugLogExtra($"Creating anchor at initial ({initialPose.position.x:0.000}, {initialPose.position.y:0.000}, {initialPose.position.z:0.000})"); XRAnchor xrAnchor; bool created = xrAnchorManager.TryAddAnchor(initialPose, out xrAnchor); if (created) { spongyAnchorXR = PrepAnchor(id, parent, xrAnchor.trackableId, xrAnchor.pose); } } return(spongyAnchorXR); }
IEnumerator AddAndCheckAnchor(Action <TrackableId> callback) { XRAnchorSubsystem rpsub = ActiveLoader.GetLoadedSubsystem <XRAnchorSubsystem>(); Assert.NotNull(rpsub); XRAnchor rp; bool ret = rpsub.TryAddAnchor(defaultPose, out rp); Assert.IsTrue(ret); Assert.AreNotEqual(defaultId, rp.trackableId); yield return(null); TrackableChanges <XRAnchor>?currentRps = rpsub.GetChanges(Allocator.Temp); Assert.IsNotNull(currentRps); Assert.AreNotEqual(0, currentRps?.added.Length ?? 0); if (callback != null) { callback.Invoke(currentRps?.added[0].trackableId ?? defaultId); } }