unsafe void CheckPreviewJobsForCompletion() { var repaintSceneViews = false; foreach (var job in m_PreviewJobsOutput.Keys.ToArray()) // TODO: don't allocate on heap { // repaint scene views to indicate progress if most recent preview job is still in the queue var mostRecentlyScheduledJob = m_MostRecentlyScheduledJob.Equals(job); repaintSceneViews |= mostRecentlyScheduledJob; if (!job.IsCompleted) { continue; } var output = m_PreviewJobsOutput[job]; m_PreviewJobsOutput.Remove(job); job.Complete(); // only populate preview edge data if not already disposed and this job was actually the most recent if (!m_Disposed && mostRecentlyScheduledJob) { switch (((ConvexCollider *)output[0].GetUnsafePtr())->Type) { case ColliderType.Convex: DrawingUtility.GetConvexHullEdges( ref ((ConvexCollider *)output[0].GetUnsafePtr())->ConvexHull, s_ReusableEdges ); break; case ColliderType.Mesh: DrawingUtility.GetMeshEdges(ref ((MeshCollider *)output[0].GetUnsafePtr())->Mesh, s_ReusableEdges); break; } Edges = s_ReusableEdges.ToArray(); EditorApplication.delayCall += SceneViewUtility.ClearNotificationInSceneView; } output[0].Release(); output.Dispose(); } if (repaintSceneViews) { SceneView.RepaintAll(); } if (m_PreviewJobsOutput.Count == 0) { EditorApplication.update -= CheckPreviewJobsForCompletion; } }