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
- “Default Scene” dropdown field contains a spelling mistake “Default Builtin”
- Editor crashes on PPtr<Mesh> after adding Text Mesh and Cloth Components to the same GameObject
- Previously deleted “DefaultLookDevProfile“ is present when upgrading the Editor version
- [Ubuntu] UI text and buttons are missing spaces in Unity Version Control > New Workspace window
- "Inherit attribute is not supported" warning is shown but attributes are available in VFX Graph Output and Update blocks
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)