Stop spamming Look Rotation log when holding shift#653
Stop spamming Look Rotation log when holding shift#653jmcduff-unity wants to merge 2 commits intomasterfrom
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
🤖 Helpful? Please react with 👍/👎 | Questions❓Please reach out in Slack #ask-u-pr |
| - [PBLD-284] Fixed InstanceID obsolescence warning appearing on 6000.4 and newer versions. | ||
| - Fixed an issue where a proper unique name wasn't set on duplicated ProBuilder meshes. | ||
| - [UUM-133756] Fixed the help icon for ProBuilder components pointing to the wrong documentation link. It now points to https://docs.unity3d.com/Packages/com.unity.probuilder@latest. | ||
| - [UUM-133861] Fixed "Look rotation viewing vector is zero" log being spammed when holding shift while using a create tool such as Create Sprite. |
There was a problem hiding this comment.
I'm not sure if I added the changelog entry in the right place, let me know if it needs to be moved 😅
PR Code Suggestions ✨Explore these optional code suggestions:
🤖 Helpful? Please react with 👍/👎 | Questions❓Please reach out in Slack #ask-u-pr |
|||||||||
Codecov ReportAttention: Patch coverage is
@@ Coverage Diff @@
## master #653 +/- ##
=======================================
Coverage 36.06% 36.06%
=======================================
Files 277 277
Lines 34895 34906 +11
=======================================
+ Hits 12584 12588 +4
- Misses 22311 22318 +7
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 5 files with indirect coverage changes 🚀 New features to boost your workflow:
|
Purpose of this PR
This PR fixes a log spam that happens when holding shift while using a create tool such as Create Sprite. Repro happens consistently on a freshly opened editor. The spam stops once you've done a shift + click (which will duplicate the last created mesh).
Before:

After:
Links
Jira: UUM-133861
Comments to Reviewers
The issue seems to be that until you've duplicated at least once, the
m_PlaneForwardandm_Planefields have not yet been initialized. Holding shift however triggers down the line a call toQuaternion.LookRotation(m_PlaneForward, m_Plane.normal), which requires a vector with a non-zero magnitude.m_PlaneForwardbeing uninitialized, its magnitude is 0 andLookRotation()will send out a log (this part is a bit weird; why a log? why not a warning or an error? ¯\ _ (ツ) _ /¯ ). However, it also defaults to returning a default value ofQuaternion.identity.The chosen fix was to simply add a check before calling
LookRotationto see ifm_PlaneFowardhas a zero magnitude, and if so, to useQuaternion.identity. This allows to keep the current behaviour as it is except the log spam. There is probably a better solution, however when testing the feature, I have not found that the shift feature was working incorrectly (except for the log spam). As such, I would rather keep the risk of regression as low as possible by keeping the current behaviour largely unchanged.