From 9d53f74c4ba80de448279a6947ca55fcad8d47cc Mon Sep 17 00:00:00 2001 From: KirylTkachou Date: Tue, 23 Jul 2019 18:51:39 +0300 Subject: [PATCH] Fixed mesh duplication. --- MA_ToolBox/MA_Utilities/MeshUtils/MA_MeshUtils.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/MA_ToolBox/MA_Utilities/MeshUtils/MA_MeshUtils.cs b/MA_ToolBox/MA_Utilities/MeshUtils/MA_MeshUtils.cs index feffb45..596d05f 100644 --- a/MA_ToolBox/MA_Utilities/MeshUtils/MA_MeshUtils.cs +++ b/MA_ToolBox/MA_Utilities/MeshUtils/MA_MeshUtils.cs @@ -9,6 +9,7 @@ using System.IO; using System.Text; using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; using UnityEditor; @@ -39,12 +40,16 @@ namespace MA_Mesh public static Mesh MA_DuplicateMesh(Mesh mesh) { Mesh newMesh = new Mesh(); - + newMesh.name = mesh.name; newMesh.SetVertices(new List(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(mesh.normals)); newMesh.SetUVs(0, new List(mesh.uv)); newMesh.SetTangents(new List(mesh.tangents));