Skip to content

Bugfix/uum 133528 fixing autolightmapuv not rebuilding#689

Open
lopezt-unity wants to merge 2 commits into
masterfrom
bugfix/uum-133528-fixing-autolightmapuv-not-rebuilding
Open

Bugfix/uum 133528 fixing autolightmapuv not rebuilding#689
lopezt-unity wants to merge 2 commits into
masterfrom
bugfix/uum-133528-fixing-autolightmapuv-not-rebuilding

Conversation

@lopezt-unity

Copy link
Copy Markdown
Collaborator

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:

  • UVEditor.cs: added pb.Optimize() to the same guarded ToMesh/Refresh block in DrawAutoModeUI, plus centralized ProBuilderEditor.Refresh() calls there.
  • AutoUVEditor.cs: removed the now-redundant per-button ProBuilderEditor.Refresh() / ToMesh()/Refresh()/Optimize() calls from "Group Selected Faces," "Break Selected Groups," "Select Texture Group," and "Reset UVs" — that responsibility now lives solely in the one caller (UVEditor.DrawAutoModeUI).

Links

Jira: https://jira.unity3d.com/browse/UUM-133528

Comments to Reviewers

[List known issues, planned work, provide any extra context for your code.]

@u-pr u-pr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Harness Review

Needs changes

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();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1

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();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2

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-github-com

codecov-github-com Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
Editor/EditorCore/UVEditor.cs 0.00% 3 Missing ⚠️
@@            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     
Flag Coverage Δ
probuilder_MacOS_6000.0 36.23% <0.00%> (+0.10%) ⬆️
probuilder_MacOS_6000.3 36.23% <0.00%> (+0.10%) ⬆️
probuilder_MacOS_6000.4 36.23% <0.00%> (+0.10%) ⬆️
probuilder_MacOS_6000.5 36.23% <0.00%> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
Editor/EditorCore/AutoUVEditor.cs 0.00% <ø> (ø)
Editor/EditorCore/UVEditor.cs 39.06% <0.00%> (-0.06%) ⬇️

... and 5 files with indirect coverage changes

ℹ️ Need help interpreting these results?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant