Hi,
I want to know if this command :
Unwrapping.GenerateSecondaryUVSet( mymesh );
Automatically save something in the mesh meta ? or not ?
Hi,
I want to know if this command :
Unwrapping.GenerateSecondaryUVSet( mymesh );
Automatically save something in the mesh meta ? or not ?
Ok I got an answer if some people are interesting to do this :
//Recursive function switch all uv2 of mesh to true
private void GenerateLightMapUV2( GameObject gameObject )
{
MeshFilter meshFilter = gameObject.GetComponent<MeshFilter>();
MeshRenderer meshRenderer = gameObject.GetComponent<MeshRenderer>();
//Check if my mesh have and filter and a renderer so it's the final
if( meshFilter != null && meshRenderer != null )
{
//Take the mesh of the file
Mesh meshLightmapped = meshFilter.sharedMesh;
//Take the file's path and put it in a string
string path = AssetDatabase.GetAssetPath( meshLightmapped );
//Define a modelImporter to modify its importing settings
ModelImporter model = AssetImporter.GetAtPath( path ) as ModelImporter;
//Put the generateSecondaryUV field to true and GenerateUVSet for the mesh
model.generateSecondaryUV = true;
Unwrapping.GenerateSecondaryUVSet( meshLightmapped );
//Update the mesh setting in editor
AssetDatabase.ImportAsset( path );
}
//If the previous mesh don't have both so go in children
foreach( Transform t in gameObject.transform )
GenerateLightMapUV2( t.gameObject );
}