Skip to content

Commit

Permalink
Fixed mesh duplication.
Browse files Browse the repository at this point in the history
  • Loading branch information
goto01 committed Jul 23, 2019
1 parent 7f17793 commit 9d53f74
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion MA_ToolBox/MA_Utilities/MeshUtils/MA_MeshUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEditor;

Expand Down Expand Up @@ -39,12 +40,16 @@ public static void MA_SaveMeshAsset(Mesh mesh, string savePath, string meshName
public static Mesh MA_DuplicateMesh(Mesh mesh)
{
Mesh newMesh = new Mesh();

newMesh.name = mesh.name;
newMesh.SetVertices(new List<Vector3>(mesh.vertices));
newMesh.bounds = mesh.bounds;
newMesh.colors = mesh.colors.ToArray();
newMesh.subMeshCount = mesh.subMeshCount;
for (int i = 0; i < mesh.subMeshCount; i++)
{
newMesh.SetTriangles(mesh.GetTriangles(i), i);
}
newMesh.subMeshCount = mesh.subMeshCount;
newMesh.SetNormals(new List<Vector3>(mesh.normals));
newMesh.SetUVs(0, new List<Vector2>(mesh.uv));
newMesh.SetTangents(new List<Vector4>(mesh.tangents));
Expand Down

0 comments on commit 9d53f74

Please sign in to comment.