Пример #1
0
        /// <summary>
        /// After mesh is created, process it based on selected options
        /// </summary>
        public static void ApplyMeshPostProcessing(this Mesh mesh,
                                                   bool autoWeldVertices     = false,
                                                   float autoWeldThreshold   = 0.001f,
                                                   bool addBackFaceTriangles = false,
                                                   bool recalculateNormals   = false,
                                                   bool recalculateBounds    = true,
                                                   bool optimize             = true)
        {
            if (autoWeldVertices)
            {
                mesh.AutoWeldVertices(autoWeldThreshold);
            }

            if (addBackFaceTriangles)
            {
                mesh.AddBackFaceTriangles();
            }

            if (recalculateNormals)
            {
                mesh.RecalculateNormals();
            }

            if (recalculateBounds)
            {
                mesh.RecalculateBounds();
            }

            if (optimize)
            {
                ;
            }
        }
        /// <summary>
        /// After mesh is created, process it based on selected options
        /// </summary>
        public static void ApplyMeshPostProcessing(this Mesh mesh,
                                                   bool autoWeldVertices     = false,
                                                   float autoWeldThreshold   = 0.001f,
                                                   bool addBackFaceTriangles = false,
                                                   bool recalculateNormals   = false,
                                                   bool recalculateBounds    = true,
                                                   bool optimize             = true)
        {
            if (autoWeldVertices)
            {
                mesh.AutoWeldVertices(autoWeldThreshold);
            }

            if (addBackFaceTriangles)
            {
                mesh.AddBackFaceTriangles();
            }

            if (recalculateNormals)
            {
                mesh.RecalculateNormals();
            }

            if (recalculateBounds)
            {
                mesh.RecalculateBounds();
            }

#if UNITY_EDITOR
            if (optimize)
            {
                UnityEditor.MeshUtility.Optimize(mesh);
            }
#endif
        }