private bool UpdateTrackables()
        {
            if (xrAnchorManager == null)
            {
                return(false);
            }
            DebugLogExtra($"UpdateTrackables {Time.frameCount} XRAnchorSubsystem is {xrAnchorManager.running}");
            TrackableChanges <XRAnchor> changes = xrAnchorManager.GetChanges(Unity.Collections.Allocator.Temp);

            if (changes.isCreated && (changes.added.Length + changes.updated.Length + changes.removed.Length > 0))
            {
                DebugLogExtra($"Changes Fr{Time.frameCount:0000}: isCreated={changes.isCreated} Added={changes.added.Length}, Updated={changes.updated.Length} Removed={changes.removed.Length}");
                for (int i = 0; i < changes.added.Length; ++i)
                {
                    UpdateTracker("Added::", changes.added[i], anchorsByTrackableId);
                }
                for (int i = 0; i < changes.updated.Length; ++i)
                {
                    UpdateTracker("Updated::", changes.updated[i], anchorsByTrackableId);
                }
                for (int i = 0; i < changes.removed.Length; i++)
                {
                    RemoveTracker(changes.removed[i], anchorsByTrackableId);
                }
            }
            changes.Dispose();
            return(true);
        }
コード例 #2
0
ファイル: AnchorTests.cs プロジェクト: renasami/unity-gps
        bool CheckThereAreNoAnchors()
        {
            XRAnchorSubsystem rpsub = ActiveLoader.GetLoadedSubsystem <XRAnchorSubsystem>();

            Assert.NotNull(rpsub);

            TrackableChanges <XRAnchor>?currentRps = rpsub.GetChanges(Allocator.Temp);

            bool hasNoAnchors = (currentRps == null) ? false :
                                currentRps?.added.Length == 0 &&
                                currentRps?.removed.Length == 0 &&
                                currentRps?.updated.Length == 0;

            return(hasNoAnchors);
        }
コード例 #3
0
ファイル: AnchorTests.cs プロジェクト: renasami/unity-gps
        bool CheckAnchorUpdateState(TrackableId id, UpdateState updateState)
        {
            XRAnchorSubsystem rpsub = ActiveLoader.GetLoadedSubsystem <XRAnchorSubsystem>();

            Assert.NotNull(rpsub);

            TrackableChanges <XRAnchor>?currentRps = rpsub.GetChanges(Allocator.Temp);

            Assert.IsNotNull(currentRps);

            XRAnchor?   rp        = null;
            TrackableId idToCheck = defaultId;

            switch (updateState)
            {
            case UpdateState.Added:
                Assert.AreNotEqual(0, currentRps?.added.Length ?? 0);
                rp        = currentRps?.added[0] ?? null;
                idToCheck = rp?.trackableId ?? defaultId;
                break;

            case UpdateState.Updated:
                Assert.AreNotEqual(0, currentRps?.updated.Length ?? 0);
                rp        = currentRps?.updated[0] ?? null;
                idToCheck = rp?.trackableId ?? defaultId;
                break;

            case UpdateState.Removed:
                Assert.AreNotEqual(0, currentRps?.removed.Length ?? 0);
                idToCheck = currentRps?.removed[0] ?? defaultId;
                break;

            case UpdateState.None:
            default:
                return(false);
            }


            return(idToCheck == id);
        }
コード例 #4
0
ファイル: AnchorTests.cs プロジェクト: renasami/unity-gps
        IEnumerator RemoveAndCheckAnchor(TrackableId id, Action <TrackableId> callback)
        {
            XRAnchorSubsystem rpsub = ActiveLoader.GetLoadedSubsystem <XRAnchorSubsystem>();

            Assert.NotNull(rpsub);

            rpsub.TryRemoveAnchor(id);

            yield return(null);

            TrackableChanges <XRAnchor>?currentRps = rpsub.GetChanges(Allocator.Temp);

            Assert.IsNotNull(currentRps);
            Assert.AreNotEqual(0, currentRps?.removed.Length ?? 0);

            TrackableId?rpRemoved = currentRps?.removed[0] ?? null;

            if (callback != null)
            {
                callback.Invoke(rpRemoved ?? defaultId);
            }
        }
        private bool UpdateTrackables()
        {
            if (xrAnchorManager == null)
            {
                return(false);
            }
#if !UNITY_ANDROID && !UNITY_IOS
            if (sessionSubsystem != null)
            {
                sessionSubsystem.Update(new XRSessionUpdateParams
                {
                    screenOrientation = Screen.orientation,
                    screenDimensions  = new Vector2Int(Screen.width, Screen.height)
                });
            }
#endif // !UNITY_ANDROID && !UNITY_IOS
            DebugLogExtra($"UpdateTrackables {Time.frameCount} XRAnchorSubsystem is {xrAnchorManager.running}");
            TrackableChanges <XRAnchor> changes = xrAnchorManager.GetChanges(Unity.Collections.Allocator.Temp);
            if (changes.isCreated && (changes.added.Length + changes.updated.Length + changes.removed.Length > 0))
            {
                DebugLogExtra($"Changes Fr{Time.frameCount:0000}: isCreated={changes.isCreated} Added={changes.added.Length}, Updated={changes.updated.Length} Removed={changes.removed.Length}");
                for (int i = 0; i < changes.added.Length; ++i)
                {
                    UpdateTracker("Added::", changes.added[i], anchorsByTrackableId);
                }
                for (int i = 0; i < changes.updated.Length; ++i)
                {
                    UpdateTracker("Updated::", changes.updated[i], anchorsByTrackableId);
                }
                for (int i = 0; i < changes.removed.Length; i++)
                {
                    RemoveTracker(changes.removed[i], anchorsByTrackableId);
                }
            }
            changes.Dispose();
            return(true);
        }
コード例 #6
0
ファイル: AnchorTests.cs プロジェクト: renasami/unity-gps
        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);
            }
        }