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
- “[Worker0] Could not generate preview image“ error when opening macOS native plugin in the Inspector with Architecture to build for set to ARM 64-bit
- [iOS] Application.absoluteURL is empty on Awake/Start when opening via deep link with Splash Screen disabled
- Crash on MemoryManager::Deallocate when rapidly calling Addressables.LoadAssetAsync
- Crash on physx::shdfnd::atomicIncrement when adjusting values on a character controller component after entering Play mode in Prefab edit mode
- [Rendering Debugger] [NewInputSystem] Debug Overlays in Play mode throws InvalidOperationException when using New Input System
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)