Bugfix/uum 133528 fixing autolightmapuv not rebuilding#689
Bugfix/uum 133528 fixing autolightmapuv not rebuilding#689lopezt-unity wants to merge 2 commits into
Conversation
…operations in the uv editor
There was a problem hiding this comment.
💡 Harness Review
The change fixes the main missing-Optimize() path, but the new centralized rebuild still has one correctness gap and still conflates a selection-only UI action with a mesh edit.
Reviewed commit 155a38bc
🤖 Helpful? 👍/👎
| { | ||
| pb.ToMesh(); | ||
| pb.Refresh(); | ||
| pb.Optimize(); |
There was a problem hiding this comment.
pb.Optimize() does not reliably restore the UV2 channel that pb.ToMesh() just cleared. ToMesh() always sets mesh.uv2 = null, while Optimize() only regenerates UV2 when Auto Lightmap UVs is enabled and the mesh contributes GI, or when you pass true. That means meshes with an existing UV2 channel but no ContributeGI flag (or projects with Auto Lightmap UVs turned off) will still lose UV2 after these Auto UV actions. If the goal is to preserve lightmap UVs across this path, this needs Optimize(true) or a path that avoids ToMesh() for metadata-only edits.
🤖 Helpful? 👍/👎
| pb.Refresh(); | ||
| pb.Optimize(); | ||
| } | ||
| ProBuilderEditor.Refresh(); |
There was a problem hiding this comment.
This centralized rebuild still runs for the Select Texture Group button, even though that button only changes the face selection (SetSelectedFaces(...)) and does not modify mesh data. Because the outer EndChangeCheck() also trips on that click, a pure selection action now executes ToMesh()/Refresh()/Optimize() on every selected mesh, which can unnecessarily dirty meshes and spend a long time regenerating UV2 on large selections. It would be better to distinguish selection-only actions from mesh-editing actions instead of routing both through the same bool return.
🤖 Helpful? 👍/👎
Codecov ReportAttention: Patch coverage is
@@ Coverage Diff @@
## master #689 +/- ##
==========================================
+ Coverage 38.43% 38.52% +0.08%
==========================================
Files 279 279
Lines 39164 39170 +6
==========================================
+ Hits 15052 15089 +37
+ Misses 24112 24081 -31
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Purpose of this PR
Problem: Using any Auto UV panel action in the UV Editor (e.g. "Group Selected Faces") cleared the mesh's Lightmap UVs (UV2/TexCoord1) without regenerating them, even though these actions don't necessarily touch geometry.
Root cause: AutoUVEditor.OnGUI wraps its whole panel in a single EditorGUI.BeginChangeCheck()/EndChangeCheck(), so any interaction — including a button click that only sets face metadata — registers as a change. The caller, UVEditor.DrawAutoModeUI, responded to that by calling pb.ToMesh(); pb.Refresh(); on every mesh in the selection, which unconditionally clears mesh.uv2. Unlike the Planar/Box/Spherical Project actions, this path never followed up with pb.Optimize(), so the lightmap UVs were never rebuilt.
Fix:
Links
Jira: https://jira.unity3d.com/browse/UUM-133528
Comments to Reviewers
[List known issues, planned work, provide any extra context for your code.]