예제 #1
0
        void Awake()
        {
            arSession = FindObjectOfType <ARSession>();

            #if UNITY_IOS && !UNITY_EDITOR
            if (arSession.subsystem is ARKitSessionSubsystem)
            {
                arKitSessionSubsystem = arSession.subsystem as ARKitSessionSubsystem;
            }
            #endif
        }
예제 #2
0
 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);
             }
         }
     }
 }
예제 #3
0
 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());
             }
         }
     }
 }
예제 #4
0
        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();
            }
        }
예제 #5
0
        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());
            }
        }
예제 #6
0
    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);
                }
            }
        }
    }
예제 #7
0
    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();
                }
            }
        }
    }
예제 #8
0
 protected override void OnConfigurationChanged(ARKitSessionSubsystem sessionSubsystem)
 {
     Debug.Log("OnConfigurationChanged");
 }
예제 #9
0
 protected override void OnCoachingOverlayViewDidDeactivate(ARKitSessionSubsystem sessionSubsystem)
 {
     Debug.Log("OnCoachingOverlayViewDidDeactivate");
     GameManager.Instance.CoachingCompleted();
 }
예제 #10
0
 protected override void OnCoachingOverlayViewWillActivate(ARKitSessionSubsystem sessionSubsystem)
 {
     Debug.Log("OnCoachingOverlayViewWillActivate");
     GameManager.Instance.CoachingInProgress();
 }
예제 #11
0
 protected override void OnSessionDidFailWithError(ARKitSessionSubsystem sessionSubsystem, NSError error)
 {
     Debug.Log("OnSessionDidFailWithError: " + error.AsARKitErrorCode());
 }
예제 #12
0
 protected override void OnCoachingOverlayViewWillActivate(ARKitSessionSubsystem sessionSubsystem)
 {
     Logger.Log(nameof(OnCoachingOverlayViewWillActivate));
 }
예제 #13
0
 protected override void OnCoachingOverlayViewDidDeactivate(ARKitSessionSubsystem sessionSubsystem)
 {
     Logger.Log(nameof(OnCoachingOverlayViewDidDeactivate));
     ScriptManager.OnCompletedCallback("ARKitCoachingOverlay", "ARKitCoachingOverlay OnDisabled");
 }