Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


GenerateSecondaryUVSet

Compute a unique UV layout for a Mesh, and store it in Mesh.uv2.
Read time 2 minutesLast updated 12 days ago

Definition

  • Type: Method
  • Namespace: UnityEditor
  • Assembly: UnityEditor.CoreModule

GenerateSecondaryUVSet(Mesh)

Compute a unique UV layout for a Mesh, and store it in Mesh.uv2.
public static bool GenerateSecondaryUVSet(Mesh src)

Parameters

src

The Mesh to update.

Returns

Type

Description

boolReturns true if the calculation succeeded. Otherwise, returns false.

Remarks

When you import a model asset, you can instruct Unity to compute a lightmap UV layout for it using ModelImporter-generateSecondaryUV or the Model Import Settings Inspector. This function allows you to do the same to procedurally generated meshes.
If this process requires multiple UV charts to flatten the the mesh, the mesh might contain more vertices than before. If the mesh uses 16-bit indices (see Mesh.indexFormat) and the process would result in more vertices than are possible to use with 16-bit indices, this function fails and returns
false
.
Additional Resources: Mesh class, ModelImporter class, Generating Lightmap UVs.

GenerateSecondaryUVSet(Mesh, UnwrapParam)

Compute a unique UV layout for a Mesh, and store it in Mesh.uv2.
public static bool GenerateSecondaryUVSet(Mesh src, UnwrapParam settings)

Parameters

src

The Mesh to update.

settings

Settings that configure the calculation.

Returns

Type

Description

boolReturns true if the calculation succeeded. Otherwise, returns false.

Remarks

When you import a model asset, you can instruct Unity to compute a lightmap UV layout for it using ModelImporter-generateSecondaryUV or the Model Import Settings Inspector. This function allows you to do the same to procedurally generated meshes.
If this process requires multiple UV charts to flatten the the mesh, the mesh might contain more vertices than before. If the mesh uses 16-bit indices (see Mesh.indexFormat) and the process would result in more vertices than are possible to use with 16-bit indices, this function fails and returns
false
.
Additional Resources: Mesh class, ModelImporter class, Generating Lightmap UVs.