2021-01-17 04:27:57 +01:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
namespace TAO.VertexAnimation
|
|
|
|
{
|
|
|
|
public static class MeshUtils
|
|
|
|
{
|
2021-02-17 00:49:03 +01:00
|
|
|
// Copy a mesh and it's properties.
|
2021-01-17 04:27:57 +01:00
|
|
|
public static Mesh Copy(this Mesh mesh)
|
|
|
|
{
|
|
|
|
Mesh copy = new Mesh
|
|
|
|
{
|
|
|
|
name = mesh.name,
|
2021-01-20 13:20:28 +01:00
|
|
|
indexFormat = mesh.indexFormat,
|
2021-01-17 04:27:57 +01:00
|
|
|
vertices = mesh.vertices,
|
|
|
|
triangles = mesh.triangles,
|
|
|
|
normals = mesh.normals,
|
|
|
|
tangents = mesh.tangents,
|
|
|
|
colors = mesh.colors,
|
2021-02-18 03:19:07 +01:00
|
|
|
bounds = mesh.bounds,
|
2021-01-17 04:27:57 +01:00
|
|
|
uv = mesh.uv,
|
|
|
|
uv2 = mesh.uv2,
|
|
|
|
uv3 = mesh.uv3,
|
|
|
|
uv4 = mesh.uv4,
|
|
|
|
uv5 = mesh.uv5,
|
|
|
|
uv6 = mesh.uv6,
|
|
|
|
uv7 = mesh.uv7,
|
2021-01-20 13:20:28 +01:00
|
|
|
uv8 = mesh.uv8
|
2021-01-17 04:27:57 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
return copy;
|
|
|
|
}
|
2021-02-17 00:49:03 +01:00
|
|
|
|
|
|
|
// Optimize the mesh and upload the mesh data, makes the mesh no longer readable.
|
|
|
|
public static void Finalize(this Mesh mesh)
|
|
|
|
{
|
|
|
|
mesh.Optimize();
|
|
|
|
mesh.UploadMeshData(true);
|
|
|
|
}
|
2021-01-17 04:27:57 +01:00
|
|
|
}
|
|
|
|
}
|