예제 #1
0
        /// <summary>
        /// Starts the session. If no session exists, one will be created.
        /// </summary>
        /// In order for the property <see cref="IsSessionStarted"/> and events
        /// like <see cref="SessionStarted"/> and <see cref="SessionStopped"/>
        /// to be tracked correctly, use the <see cref="StartSessionAsync"/> and
        /// <see cref="StopSession"/> methods rather than calling methods
        /// directly on the <see cref="Session"/> instance.
        /// </remarks>
        public async Task StartSessionAsync()
        {
            // Warn if already started
            if (isSessionStarted)
            {
                Debug.LogWarning($"{nameof(StartSessionAsync)} called but session is already started.");
                return;
            }

            // If no session created, create one
            if (session == null)
            {
                Debug.Log($"{nameof(StartSessionAsync)} called with but no session. Creating one.");
                await CreateSessionAsync();
            }

            // Start the session
            session.Start();

            // It's started
            isSessionStarted = true;

            // Wait for first session update
            sessionStatus = await session.GetSessionStatusAsync();

            // Notify
            OnSessionStarted();
        }
예제 #2
0
 private void Start()
 {
     _cloudAnchorSession.Start();
     _cloudAnchorSession.TokenRequired  += _cloudAnchorSession_TokenRequired;
     _cloudAnchorSession.SessionUpdated += _cloudAnchorSession_SessionUpdated;
     _cloudAnchorSession.Error          += _cloudAnchorSession_Error;
 }
예제 #3
0
    /// <summary>
    /// 新しいCloudSpatialAnchorセッションを初期化
    /// </summary>
    void ASAInitializeSession()
    {
        Debug.Log("ASA Info: Initializing a CloudSpatialAnchorSession.");

        if (string.IsNullOrEmpty(SpatialAnchorsAccountId))
        {
            Debug.LogError("アカウントIDが設定されていません。");
            return;
        }

        if (string.IsNullOrEmpty(SpatialAnchorsAccountKey))
        {
            Debug.LogError("アカウントキーが設定されていません。");
            return;
        }

        cloudSpatialAnchorSession = new CloudSpatialAnchorSession();

        cloudSpatialAnchorSession.Configuration.AccountId  = SpatialAnchorsAccountId.Trim();
        cloudSpatialAnchorSession.Configuration.AccountKey = SpatialAnchorsAccountKey.Trim();

        cloudSpatialAnchorSession.LogLevel = SessionLogLevel.All;

        cloudSpatialAnchorSession.Error                  += CloudSpatialAnchorSession_Error;
        cloudSpatialAnchorSession.OnLogDebug             += CloudSpatialAnchorSession_OnLogDebug;
        cloudSpatialAnchorSession.SessionUpdated         += CloudSpatialAnchorSession_SessionUpdated;
        cloudSpatialAnchorSession.AnchorLocated          += CloudSpatialAnchorSession_AnchorLocated;
        cloudSpatialAnchorSession.LocateAnchorsCompleted += CloudSpatialAnchorSession_LocateAnchorsCompleted;

        cloudSpatialAnchorSession.Start();
        Debug.Log("ASA Info: セッションは初期化されました。");
    }
예제 #4
0
    /// <summary>
    /// Initializes a new CloudSpatialAnchorSessions.
    /// </summary>
    void InitializeSession()
    {
        Debug.Log("ASA Info: Initializing a CloudSpatialAnchorSession.");

        if (string.IsNullOrEmpty(SpatialAnchorsAccountId))
        {
            Debug.LogError("No account id set.");
            return;
        }

        if (string.IsNullOrEmpty(SpatialAnchorsAccountKey))
        {
            Debug.LogError("No account key set.");
            return;
        }

        cloudSpatialAnchorSession = new CloudSpatialAnchorSession();

        cloudSpatialAnchorSession.Configuration.AccountId  = SpatialAnchorsAccountId.Trim();
        cloudSpatialAnchorSession.Configuration.AccountKey = SpatialAnchorsAccountKey.Trim();

        cloudSpatialAnchorSession.LogLevel = SessionLogLevel.All;

        cloudSpatialAnchorSession.Error                  += CloudSpatialAnchorSession_Error;
        cloudSpatialAnchorSession.OnLogDebug             += CloudSpatialAnchorSession_OnLogDebug;
        cloudSpatialAnchorSession.SessionUpdated         += CloudSpatialAnchorSession_SessionUpdated;
        cloudSpatialAnchorSession.AnchorLocated          += CloudSpatialAnchorSession_AnchorLocated;
        cloudSpatialAnchorSession.LocateAnchorsCompleted += CloudSpatialAnchorSession_LocateAnchorsCompleted;

        cloudSpatialAnchorSession.Start();

        Debug.Log("ASA Info: Session was initialized.");
    }
예제 #5
0
    /// <summary>
    /// Initializes a new CloudSpatialAnchorSession
    /// </summary>
    private void initializeSession()
    {
        Debug.Log("ASA Info: Initializing a CloudSpatialAnchorSession.");

        /*
         * Error Checks
         */
        if (string.IsNullOrEmpty(spatialAnchorsAccountId))
        {
            Debug.LogError("No account id set.");
            return;
        }

        if (string.IsNullOrEmpty(spatialAnchorsAccountKey))
        {
            Debug.LogError("No account key set.");
            return;
        }

        // Can't simulate on Unity Editor so we are just going to skip it
        if (Application.isEditor)
        {
            Debug.Log("ASA: Simulating initialization process in editor.");
            return;
        }

        /*
         * Initialization
         */
        // Create a session to interact with the ASA service
        CloudSpatialAnchorSession = new CloudSpatialAnchorSession();

        // Credentials
        CloudSpatialAnchorSession.Configuration.AccountId     = spatialAnchorsAccountId.Trim();
        CloudSpatialAnchorSession.Configuration.AccountKey    = spatialAnchorsAccountKey.Trim();
        CloudSpatialAnchorSession.Configuration.AccountDomain = spatialAnchorsDomain.Trim();

        // Debug Logs
        CloudSpatialAnchorSession.LogLevel = SessionLogLevel.All;

        // Logging Callbacks
        CloudSpatialAnchorSession.Error      += CloudSpatialAnchorSession_Error;
        CloudSpatialAnchorSession.OnLogDebug += CloudSpatialAnchorSession_OnLogDebug;

        // Anchor Creation Callback
        CloudSpatialAnchorSession.SessionUpdated += CloudSpatialAnchorSession_SessionUpdated;

        // Anchor Location Callbacks
        CloudSpatialAnchorSession.AnchorLocated          += CloudSpatialAnchorSession_AnchorLocated;
        CloudSpatialAnchorSession.LocateAnchorsCompleted += CloudSpatialAnchorSession_LocateAnchorsCompleted;

        // Start the Session
        CloudSpatialAnchorSession.Start();

        Debug.Log("ASA Info: Session was initialized.");
    }
예제 #6
0
        private void RequestSessionStart()
        {
            lock (session)
            {
                if (requestsForSessionStart == 0)
                {
                    session.Start();
                }

                requestsForSessionStart++;
            }
        }
예제 #7
0
        /// <summary>
        /// Starts the session. If no session exists, one will be created.
        /// </summary>
        /// In order for the property <see cref="IsSessionStarted"/> and events
        /// like <see cref="SessionStarted"/> and <see cref="SessionStopped"/>
        /// to be tracked correctly, use the <see cref="StartSessionAsync"/> and
        /// <see cref="StopSession"/> methods rather than calling methods
        /// directly on the <see cref="Session"/> instance.
        /// </remarks>
        public async Task StartSessionAsync()
        {
            Debug.Log("Anchors @ start " + arAnchorManager.trackables.count);
            // Warn if already started
            if (isSessionStarted)
            {
                Debug.LogWarning($"{nameof(StartSessionAsync)} called but session is already started.");
                return;
            }

            // If no session created, create one
            if (session == null)
            {
                Debug.Log($"{nameof(StartSessionAsync)} called with but no session. Creating one.");
                await CreateSessionAsync();
            }

            Debug.Log("Anchors before session.start " + arAnchorManager.trackables.count);

            // Start the session
            session.Start();

            Debug.Log("Anchors after session.start " + arAnchorManager.trackables.count);

            // It's started
            isSessionStarted = true;

            Debug.Log("Anchors before status " + arAnchorManager.trackables.count);

            // Wait for first session update
            sessionStatus = await session.GetSessionStatusAsync();

            Debug.Log("Anchors after status " + arAnchorManager.trackables.count);

            //Debug.Log("StartSessionAsync:");
            //Debug.Log("Session: " + session.Session);
            //Debug.Log("SessionId: " + session.SessionId);
            //Debug.Log("AccountId: " + session.Configuration.AccountId);
            //Debug.Log("AccountKey: " + session.Configuration.AccountKey);
            //Debug.Log("aRSession: " + arSession.subsystem.nativePtr);
            //Debug.Log("aRSessionPlatformPtr: " + arSession.subsystem.nativePtr.GetPlatformPointer());
            //Debug.Log("arSession.subsystem.sessionId: " + arSession.subsystem.sessionId);

            // Notify
            OnSessionStarted();
            Debug.Log("Anchors after notify " + arAnchorManager.trackables.count);
        }
예제 #8
0
    // Initial Session
    private void InitializeCloudSession()
    {
        cloudSpatialAnchorSession = new CloudSpatialAnchorSession();

        cloudSpatialAnchorSession.Configuration.AccountId  = SpatialAnchorsAccountId.Trim();
        cloudSpatialAnchorSession.Configuration.AccountKey = SpatialAnchorsAccountKey.Trim();

        cloudSpatialAnchorSession.LogLevel = SessionLogLevel.All;

        cloudSpatialAnchorSession.Error                  += CloudSpatialAnchorSession_Error;
        cloudSpatialAnchorSession.OnLogDebug             += CloudSpatialAnchorSession_OnLogDebug;
        cloudSpatialAnchorSession.SessionUpdated         += CloudSpatialAnchorSession_SessionUpdated;
        cloudSpatialAnchorSession.AnchorLocated          += CloudSpatialAnchorSession_AnchorLocated;
        cloudSpatialAnchorSession.LocateAnchorsCompleted += CloudSpatialAnchorSession_LocateAnchorsCompleted;

        cloudSpatialAnchorSession.Start();
        Debug.Log("ASA Info: Session was initialized.");
    }
예제 #9
0
    /// <summary>
    /// Starts a new Azure Spatial Anchor session.
    /// </summary>
    private void StartSession()
    {
#if !UNITY_EDITOR
        Debug.Log("Initializing Azure Spatial Anchor session.");

        if (string.IsNullOrEmpty(AzureSpatialAnchorsConfiguration.SpatialAnchorsAccountId))
        {
            Debug.LogError("Azure Spatial Anchor account ID is not set.");
            return;
        }

        if (string.IsNullOrEmpty(AzureSpatialAnchorsConfiguration.SpatialAnchorsAccountKey))
        {
            Debug.LogError("Azure Spatial Anchor account key is not set.");
            return;
        }

        if (string.IsNullOrEmpty(AzureSpatialAnchorsConfiguration.SpatialAnchorsAccountDomain))
        {
            Debug.LogError("Azure Spatial Anchor account domain is not set.");
            return;
        }

        cloudSpatialAnchorSession = new CloudSpatialAnchorSession();

        cloudSpatialAnchorSession.Configuration.AccountId     = AzureSpatialAnchorsConfiguration.SpatialAnchorsAccountId.Trim();
        cloudSpatialAnchorSession.Configuration.AccountKey    = AzureSpatialAnchorsConfiguration.SpatialAnchorsAccountKey.Trim();
        cloudSpatialAnchorSession.Configuration.AccountDomain = AzureSpatialAnchorsConfiguration.SpatialAnchorsAccountDomain.Trim();

        cloudSpatialAnchorSession.LogLevel = SessionLogLevel.All;

        cloudSpatialAnchorSession.Error                  += CloudSpatialAnchorSession_Error;
        cloudSpatialAnchorSession.OnLogDebug             += CloudSpatialAnchorSession_OnLogDebug;
        cloudSpatialAnchorSession.SessionUpdated         += CloudSpatialAnchorSession_SessionUpdated;
        cloudSpatialAnchorSession.AnchorLocated          += CloudSpatialAnchorSession_AnchorLocated;
        cloudSpatialAnchorSession.LocateAnchorsCompleted += CloudSpatialAnchorSession_LocateAnchorsCompleted;

        cloudSpatialAnchorSession.Start();
#else
        Debug.Log("Azure Spatial Anchor session can't be started when running in the Unity Editor.");
#endif
    }
예제 #10
0
    private void CreateNewCloudSession()
    {
        cloudSpatialAnchorSession = new CloudSpatialAnchorSession();
        string accountId  = "set this";
        string accountKey = "set this";

        cloudSpatialAnchorSession.Configuration.AccountId  = accountId.Trim();
        cloudSpatialAnchorSession.Configuration.AccountKey = accountKey.Trim();

        cloudSpatialAnchorSession.LogLevel = SessionLogLevel.Information;

        cloudSpatialAnchorSession.OnLogDebug             += CloudSpatialAnchorSession_OnLogDebug;
        cloudSpatialAnchorSession.SessionUpdated         += CloudSpatialAnchorSession_SessionUpdated;
        cloudSpatialAnchorSession.AnchorLocated          += CloudSpatialAnchorSession_AnchorLocated;
        cloudSpatialAnchorSession.LocateAnchorsCompleted += CloudSpatialAnchorSession_LocateAnchorsCompleted;
        cloudSpatialAnchorSession.Error += CloudSpatialAnchorSession_Error;
        feedback.text = "Starting the session!";

        cloudSpatialAnchorSession.Start();
        feedback.text = "Look for next";
    }
예제 #11
0
    void InitializeSession()
    {
        Log("Initializing CloudSpatialAnchorSession.");

        // TODO: Provide your Azure Spatial Anchors AccountId and Primary ASA Key below (ConstantsSecret is not part of the code repo)
        if (String.IsNullOrEmpty(ConstantsSecret.AsaAccountId) || String.IsNullOrEmpty(ConstantsSecret.AsaKey))
        {
            Log("Azure Spatial Anchors Account ID or Account Key are not set.", Color.red);
            return;
        }

        _cloudSpatialAnchorSession = new CloudSpatialAnchorSession();
        _cloudSpatialAnchorSession.Configuration.AccountId  = ConstantsSecret.AsaAccountId;
        _cloudSpatialAnchorSession.Configuration.AccountKey = ConstantsSecret.AsaKey;
        _cloudSpatialAnchorSession.SessionUpdated          += CloudSpatialAnchorSession_SessionUpdated;
        _cloudSpatialAnchorSession.AnchorLocated           += CloudSpatialAnchorSession_AnchorLocated;
        _cloudSpatialAnchorSession.Error += CloudSpatialAnchorSession_Error;
        _cloudSpatialAnchorSession.Start();

        Log("ASA session initialized.\r\n Gaze and tap to place an anchor.");
    }
예제 #12
0
    private async Task startSessionAsync()
    {
        if (sessionIsStarted)
        {
            //session already started
            return;
        }

        if (cloudSession == null)
        {
            //session already created
            await createSessionAsync();
        }

        cloudSession.Start();

        debugText.text += "\nSession Started";
        debugText.text += "\nSession Pointer: " + cloudSession.Session;
        debugText.text += "\nSession Id: " + cloudSession.SessionId;

        sessionIsStarted = true;
    }
        private void CreateNewCloudSession()
        {
            cloudSession = new CloudSpatialAnchorSession();
            cloudSession.Configuration.AccountId  = @"2c54fa04-44c0-4b61-a848-4f86395311aa";
            cloudSession.Configuration.AccountKey = @"JOmr5g1hpJyCOVqFs95MNQ5B1Z5w7S23mFoBeKRSm/I=";
#if UNITY_IOS
            cloudSpatialAnchorSession.Session = arkitSession.GetNativeSessionPtr();
#elif UNITY_ANDROID
            cloudSession.Session = GoogleARCoreInternal.ARCoreAndroidLifecycleManager.Instance.NativeSession.SessionHandle;
#elif UNITY_WSA || WINDOWS_UWP
            // No need to set a native session pointer for HoloLens.
#else
            throw new NotSupportedException("The platform is not supported.");
#endif
            cloudSession.LogLevel = SessionLogLevel.All;

            cloudSession.Error          += CloudSession_Error;
            cloudSession.OnLogDebug     += CloudSession_OnLogDebug;
            cloudSession.SessionUpdated += CloudSession_SessionUpdated;
            cloudSession.Start();

            Debug.Log(DEBUG_FILTER + "Session was initialized.");
        }
 public void Start()
 {
     spatialAnchorsSession.Start();
     IsRunning = true;
 }