/// <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(); }
/// <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); }