コード例 #1
0
        /// <summary>
        /// Resets the current session if there is one, and waits for any
        /// active queries to be stopped.
        /// </summary>
        /// <returns>
        /// A <see cref="Task"/> that represents the operation.
        /// </returns>
        public async Task ResetSessionAsync()
        {
            // Capture if session was started
            bool wasStarted = isSessionStarted;

            // Stop the session if it was started
            if (isSessionStarted)
            {
                StopSession();
            }

            // Reset the current session if there is one
            if (session != null)
            {
                session.Reset();
            }

            // Wait for any currently active locate operations to be stopped
            await Task.Run(async() =>
            {
                while (IsLocating)
                {
                    await Task.Delay(20);
                }
            });

            // Restart the session if it was running before the reset
            if (wasStarted)
            {
                await StartSessionAsync();
            }
        }
コード例 #2
0
    /// <summary>
    /// Cleans up objects and stops the CloudSpatialAnchorSessions.
    /// </summary>
    public void ResetSession(Action completionRoutine = null)
    {
        Debug.Log("ASA Info: Resetting the session.");

        if (cloudSpatialAnchorSession.GetActiveWatchers().Count > 0)
        {
            Debug.LogError("ASA Error: We are resetting the session with active watchers, which is unexpected.");
        }

        CleanupObjects();

        cloudSpatialAnchorSession.Reset();

        lock (dispatchQueue)
        {
            dispatchQueue.Enqueue(() =>
            {
                if (cloudSpatialAnchorSession != null)
                {
                    cloudSpatialAnchorSession.Stop();
                    cloudSpatialAnchorSession.Dispose();
                    Debug.Log("ASA Info: Session was reset.");
                    completionRoutine?.Invoke();
                }
                else
                {
                    Debug.LogError("ASA Error: cloudSpatialAnchorSession was null, which is unexpected.");
                }
            });
        }
    }
コード例 #3
0
    /// <summary>
    /// Resets and stops the Azure Spatial Anchor session.
    /// </summary>
    public void StopSession(Action completionRoutine = null)
    {
#if !UNITY_EDITOR
        cloudSpatialAnchorSession.Reset();

        lock (queue)
        {
            queue.Enqueue(() =>
            {
                if (cloudSpatialAnchorSession != null)
                {
                    cloudSpatialAnchorSession.Stop();
                    cloudSpatialAnchorSession.Dispose();
                    completionRoutine?.Invoke();
                }
            });
        }
#endif
    }
コード例 #4
0
    // Public Methods: Session
    public void ResetCloudSession(Action completionRoutine = null)
    {
        Debug.Log("ASA Info: Resetting the session.");
        bool sessionWasEnabled = EnableSession; // Record the status before the reset

        EnableSession = false;                  // cloudSpatialAnchorSession.Stop()
        cloudSpatialAnchorSession.Reset();      // Reset session
        ResetSessionStatusIndicators();         // Reset indicators
        Task.Run(async() =>
        {
            while (LocateOperationInFlight())
            {
                await Task.Yield();  //????
            }
            lock (dispatchQueue)
            {
                dispatchQueue.Enqueue(() =>
                {
                    EnableSession = sessionWasEnabled;
                    completionRoutine?.Invoke();
                });
            }
        });
    }
 public void Reset()
 {
     StopLocating();
     spatialAnchorsSession.Reset();
 }