Search Issue Tracker
By Design
Votes
0
Found in
2017.3.1f1
Issue ID
1009570
Regression
No
Calculation errors in Camera API's World/Screen space transformation functions
How to reproduce:
1. Download attached project and open "Default" Scene
2. Click anywhere in the Scene Window and compare the debug outputs with the code contained in TrackEditorMouse.HandleEvent().
3. Fit the SceneView camera (perspective mode) to view the entire cube contained in the scene.
4. Click the outmost pixel on any of the corners of the cube.
5. Move the Scene Window camera around to inspect the two rays calculated from the mouse click (without clicking the left mouse button again)
6. The green ray (my method) will be more accurate than the red ray (Camera.ScreenPointToRay()), but BOTH are off target.
Actual result: The functions Camera.WorldToScreenPoint(), Camera.ScreenToWorldPoint(), Camera.ScreenPointToRay(), Camera.pixelHeight and other Camera-related functions yield slightly incorrect results.
Reproduced with: 2017.1.3p2, 2017.2.2f1, 2017.3.1p3, 2018.1.0b10, 2018.2.0a3
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Console shows Exception: {"error":"not found","detail":["not found"]} after opening Build History window
- [HDRP] Volumetric cloud shadows disappear when there is no directional light shadows
- “Selector” column names in the Search window are lowercase when added
- Install List Project Counter Panel can be right clicked through and Install Context Menu can be opened disabling Project Counter Panel's buttons
- [MacOS] Scene is marked/flickering as dirty (with asterisk) when dragging a Material on a GameObject in Scene view
Resolution Note:
This is actually expected behavior. The calculation for screenCenter is correct, the calculation for expectedScreenCenter is not.
You should really be using "c.pixelRect.center", and not (c.pixelWidth*0.5f, c.pixelHeight*0.5f)