Skip to content

Commit

Permalink
Copy over all UV channels.
Browse files Browse the repository at this point in the history
The duplicate function now copies all 8 UV channels. So your lightmap UV's don't get lost!
  • Loading branch information
maxartz15 committed Mar 26, 2021
1 parent df16ba6 commit b2ccdb2
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
54 changes: 54 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Unity Editor",
"type": "unity",
"path": "/D:/PerforceMax/Projects/Unity/MA_TextureAtlasser/Library/EditorInstance.json",
"request": "launch"
},
{
"name": "Windows Player",
"type": "unity",
"request": "launch"
},
{
"name": "OSX Player",
"type": "unity",
"request": "launch"
},
{
"name": "Linux Player",
"type": "unity",
"request": "launch"
},
{
"name": "iOS Player",
"type": "unity",
"request": "launch"
},
{
"name": "Android Player",
"type": "unity",
"request": "launch"
},
{
"name": "Xbox One Player",
"type": "unity",
"request": "launch"
},
{
"name": "PS4 Player",
"type": "unity",
"request": "launch"
},
{
"name": "SwitchPlayer",
"type": "unity",
"request": "launch"
}
]
}
7 changes: 6 additions & 1 deletion Assets/MA_ToolBox/MA_Utilities/MeshUtils/MA_MeshUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,12 @@ public static Mesh MA_DuplicateMesh(Mesh mesh)
newMesh.SetTriangles(mesh.GetTriangles(i), i);
}
newMesh.SetNormals(new List<Vector3>(mesh.normals));
newMesh.SetUVs(0, new List<Vector2>(mesh.uv));
for (int i = 0; i < 8; i++)
{
List<Vector2> uvs = new List<Vector2>();
mesh.GetUVs(i, uvs);
newMesh.SetUVs(i, uvs);
}
newMesh.SetTangents(new List<Vector4>(mesh.tangents));
newMesh.SetColors(new List<Color>(mesh.colors));

Expand Down

0 comments on commit b2ccdb2

Please sign in to comment.