Exemple #1
0
        void OnDisable()
        {
            Undo.undoRedoPerformed -= Repaint;

            SceneViewUtility.ClearNotificationInSceneView();

            foreach (var preview in m_PreviewData.Values)
            {
                preview.Dispose();
            }

            if (m_DropDown != null)
            {
                m_DropDown.CloseWithoutUndo();
            }
        }
Exemple #2
0
            public void SchedulePreviewIfChanged(PhysicsShapeAuthoring shape)
            {
                using (var currentPoints = new NativeList <float3>(65535, Allocator.Temp))
                {
                    var hash = GetInputHash(
                        shape, currentPoints, m_HashedPoints, m_HashedConvexParameters, out var currentConvexParameters
                        );
                    if (m_InputHash == hash)
                    {
                        return;
                    }

                    m_InputHash = hash;
                    m_HashedConvexParameters = currentConvexParameters;
                    m_HashedPoints.Dispose();
                    m_HashedPoints = new NativeArray <float3>(currentPoints.Length, Allocator.Persistent);
                    m_HashedPoints.CopyFrom(currentPoints);
                }

                if (shape.ShapeType != ShapeType.ConvexHull && shape.ShapeType != ShapeType.Mesh)
                {
                    return;
                }

                // TODO: cache results per input data hash, and simply use existing data (e.g., to make undo/redo faster)
                var output = new NativeArray <BlobAssetReference <Collider> >(1, Allocator.Persistent);

                m_MostRecentlyScheduledJob = shape.ShapeType == ShapeType.Mesh
                    ? ScheduleMeshPreview(shape, output)
                    : ScheduleConvexHullPreview(shape, output);
                m_PreviewJobsOutput.Add(m_MostRecentlyScheduledJob, output);
                if (m_PreviewJobsOutput.Count == 1)
                {
                    CheckPreviewJobsForCompletion();
                    EditorApplication.update    += CheckPreviewJobsForCompletion;
                    EditorApplication.delayCall += () =>
                    {
                        SceneViewUtility.DisplayProgressNotification(
                            Styles.PreviewGenerationNotification, () => float.PositiveInfinity
                            );
                    };
                }
            }