VertexAnimation/Runtime/Scripts/ModelBaker/MeshUtils.cs

42 lines
812 B
C#
Raw Normal View History

using UnityEngine;
namespace TAO.VertexAnimation
{
public static class MeshUtils
{
// Copy a mesh and it's properties.
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,
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,
uv = mesh.uv,
uv2 = mesh.uv2,
uv3 = mesh.uv3,
uv4 = mesh.uv4,
uv5 = mesh.uv5,
uv6 = mesh.uv6,
uv7 = mesh.uv7,
uv8 = mesh.uv8,
};
return copy;
}
// 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);
}
}
}