I’ve met a problem with generating UV2 field for generated meshes using Unwrapping.GenerateSecondaryUVSet(). I thought this problem is somehow related to the way I’ve created these meshes, though it happens even for standard Unity objects.
Suppose we have these lighting setting
Settings
and settings for directional light
Directional light
Now for the lone object we have this code:
static public void GenerateSecUV()
{
var currentScene = EditorSceneManager.GetActiveScene ();
Transform selection = Selection.GetTransforms (SelectionMode.Editable | SelectionMode.ExcludePrefab)[0];
var meshF = selection.GetComponent<MeshFilter> ()ж
Mesh mesh = mesh.sharedMesh;
Unwrapping.GenerateSecondaryUVSet (mesh);
EditorSceneManager.MarkSceneDirty(currentScene);
EditorSceneManager.SaveScene (currentScene);
}
Now let us have standard Unity cube, use beforementioned code, nake him static and bake with these parameters.
Result
Now we have some creepy thing. Looking at baked UV we can see this:
UVs
The same thing happen when I tried to bake my own generated object (sofa). It was like baking happened at the right places (where UV coords are) but with wrong light and not “complete”.
I have new Unity 2017.1.1f1. I’ve had the same problem with Unity 5 and thought it’s some bag of Unity. It seems it is not the case…