I’m using Unity 2018.1.0f2 with ProBuilder 3.0.8 from the package manager.
My workflow is that I have a separate ProBuilder scene where I construct my meshes and than use “Tools → ProBuilder → Export → Export Asset” to create a prefab.
Back in my proper game scene I noticed that despite generating UV2s I’m getting “This GameObject has overlapping UVs” warnings in the inspector. Looking at the baked lightmap everything seems to be using the UV1 layout. Going back to my ProBuilder scene the UV2 is missing. It seems to get deleted when I export.
Is there a technical reason for this or am I doing/understanding something wrong here?
It looks to me like the UV2 channel is being exported correctly.
However, the problem you’re describing is not because UV2s are missing. Rather, some of the new project templates define a smaller lightmap resolution by default. This is too small of a padding value in some cases, which is why you’re seeing the warning. The solution is to increase the lightmap resolution (40 was the previous default value).
Thanks for the reply. I increased the lightmap resolution from 10 to 40 and this removed the warning from all the meshes which just by chance also have some padding for each face in UV1. The ones with no padding in UV1 still have the warning. It looks to me like UV2 is not exported and UV1 is used for lightmapping, if that is a thing (see uploaded file). When I have the UV Editor open and hit “Export Asset” I can see how UV2 disappears.
Could it be that checking Disable Auto UV2 Generation in the ProBuilder preferences causes this? I have auto generation disabled and doing some tests back and forth it seems I can only get UV2s to persist when auto generation is enabled.
Coming back to Unity after a while (2019.1.3f1) this still seems to be an issue and now even with Auto Lightmap UVs enabled the UV2 map is deleted on export. So currently there’s no way to export with UV2. I don’t know what I’m doing wrong if this isn’t a bug. I can clearly see how UV2 disappears in the UV Editor when I click Export Asset.
This was 4.0.5. I made a bug report back in May which was initially successfully reproduced but shortly after closed as not reproducible. After I made a video demonstration it’s now stuck on “Fix In Review for 4.1.0-preview.3”.
I was just testing again and noticed what might be a point of confusion. The export itself works afterall (even in 4.0.5) if the Contribute Global (or Lightmap Static) flag is set. All 4.1.0 seems to have fixed is that the object in the scene doesn’t lose its UV2 on export anymore.
I don’t quite see why this flag should secretly influence the export though. The decision if any particular prefab instance should be lightmapped is made in the final game scene, not when building the prefab. When I build and export a mesh I just want it to have a UV2 in case it needs one. It certainly seems confusing to me when I manually click the Generate UV2 button to make absolutely sure the mesh has one and than the export silently decides it knows better.
I see, the problem stems from the fact that ProBuilder assumes that most mesh properties are owned by the ProBuilderMesh.
UV2 in particular is a special case, and the Editor handles it differently than other mesh attributes. It isn’t really supported to keep a UV2 channel preserved through mesh operations, as the actual UV2 channel is something that is generated for the optimized form of the mesh.
When we export a mesh, there is a section that rebuilds the mesh from it’s source attributes to an optimized representation. As a part of that, we clear and rebuild UV2 (if the lightmap flag is set). In previous versions of ProBuilder we did have an action to manually generate UV2 channels, but that has since been removed to make it more explicit that we are managing the UV2 in the background based on the “Auto Lightmap UVs” preference and the GameObject static flags.
It would be possible to write an event handler after the mesh optimization step to generate UV2 regardless of static flags, if it is necessary to your workflow.
Thanks for the explanation. Now that I know what the issue is I may just set the flag for every mesh before exporting. I would definitely prefer if the flag wouldn’t be required. One less thing to keep in mind and the flag requirement isn’t intuitively clear to me (and maybe others). My workflow might be less common though and I don’t know what makes more sense in general.