void Awake() { arSession = FindObjectOfType <ARSession>(); #if UNITY_IOS && !UNITY_EDITOR if (arSession.subsystem is ARKitSessionSubsystem) { arKitSessionSubsystem = arSession.subsystem as ARKitSessionSubsystem; } #endif }
unsafe void ProcessRemoteCollaborationData(ARKitSessionSubsystem subsystem) { // Check for remote data and apply it lock (m_CollaborationDataReadQueue) { while (m_CollaborationDataReadQueue.Count > 0) { using (var collaborationData = m_CollaborationDataReadQueue.Dequeue()) { // Assume we only put in valid collaboration data into the queue. subsystem.UpdateWithCollaborationData(collaborationData); } } } }
void CheckForLocalCollaborationData(ARKitSessionSubsystem subsystem) { // Check for new data and queue it if (subsystem.collaborationDataCount > 0) { CollaborationNetworkingIndicator.NotifyHasCollaborationData(); lock (m_CollaborationDataSendQueue) { while (subsystem.collaborationDataCount > 0) { m_CollaborationDataSendQueue.Enqueue(subsystem.DequeueCollaborationData()); } } } }
static async UniTask SendCollaborationDataAsync(ARKitSessionSubsystem arKitSessionSubsystem, UnityMCSessionNativeInterface mcSession, CancellationToken cancellationToken) { while (true) { while (0 < arKitSessionSubsystem.collaborationDataCount) { var data = arKitSessionSubsystem.DequeueCollaborationData(); if (!data.valid) { continue; } mcSession.SendToAllPeers((PackableARCollaborationData)data); } await UniTask.Yield(); cancellationToken.ThrowIfCancellationRequested(); } }
public static async Task <ARWorldMap> GetARWorldMapTask(this ARKitSessionSubsystem session, CancellationToken cancellationToken = default) { using (var request = session.GetARWorldMapAsync()) { while (!request.status.IsDone()) { await Task.Yield(); cancellationToken.ThrowIfCancellationRequested(); } if (request.status.IsError()) { throw new Exception($"Session getting AR world map failed with status {request.status}"); } return(request.GetWorldMap()); } }
unsafe void ProcessRemoteCollaborationData(ARKitSessionSubsystem subsystem) { // Check for remote data and apply it lock (m_CollaborationDataReadQueue) { while (m_CollaborationDataReadQueue.Count > 0) { using (var collaborationData = m_CollaborationDataReadQueue.Dequeue()) { // Only notify user concerning large data sizes if (collaborationData.bytes.Length > 1024) { Logger.Log($"Received {collaborationData.bytes.Length} bytes from remote host. Updating session."); } CollaborationNetworkingIndicator.NotifyIncomingDataReceived(); // Assume we only put in valid collaboration data into the queue. subsystem.UpdateWithCollaborationData(collaborationData); } } } }
void CheckForLocalCollaborationData(ARKitSessionSubsystem subsystem) { // Exit if no new data is available if (subsystem.collaborationDataCount == 0) { return; } lock (m_CollaborationDataSendQueue) { // Enqueue all new collaboration data with critical priority while (subsystem.collaborationDataCount > 0) { var collaborationData = subsystem.DequeueCollaborationData(); // As all data in this sample is sent over TCP, only send critical data if (collaborationData.priority == ARCollaborationDataPriority.Critical) { m_CollaborationDataSendQueue.Enqueue(collaborationData); CollaborationNetworkingIndicator.NotifyHasCollaborationData(); } } } }
protected override void OnConfigurationChanged(ARKitSessionSubsystem sessionSubsystem) { Debug.Log("OnConfigurationChanged"); }
protected override void OnCoachingOverlayViewDidDeactivate(ARKitSessionSubsystem sessionSubsystem) { Debug.Log("OnCoachingOverlayViewDidDeactivate"); GameManager.Instance.CoachingCompleted(); }
protected override void OnCoachingOverlayViewWillActivate(ARKitSessionSubsystem sessionSubsystem) { Debug.Log("OnCoachingOverlayViewWillActivate"); GameManager.Instance.CoachingInProgress(); }
protected override void OnSessionDidFailWithError(ARKitSessionSubsystem sessionSubsystem, NSError error) { Debug.Log("OnSessionDidFailWithError: " + error.AsARKitErrorCode()); }
protected override void OnCoachingOverlayViewWillActivate(ARKitSessionSubsystem sessionSubsystem) { Logger.Log(nameof(OnCoachingOverlayViewWillActivate)); }
protected override void OnCoachingOverlayViewDidDeactivate(ARKitSessionSubsystem sessionSubsystem) { Logger.Log(nameof(OnCoachingOverlayViewDidDeactivate)); ScriptManager.OnCompletedCallback("ARKitCoachingOverlay", "ARKitCoachingOverlay OnDisabled"); }