Search Issue Tracker
Won't Fix
Votes
1
Found in
2018.4
2019.4
2020.1
2020.1.12f1
2020.2
2021.1
Issue ID
1298421
Regression
No
Canvas Raycasting does not match resolution of the Main Camera when UI Camera targets RenderTexture
How to reproduce:
1. Open the user's attached "20201205 UI Problem.zip"
2. Open the "SampleScene" Scene
3. Enter Play Mode
4. Drag the mouse on the button in the left corner of the Game view
5. Observe the Game view
Expected result: Canvas raycasting region matches the resolution of the Main Camera
Actual result: UI gets raycasted in a region that matches the pixel size of the RenderTexture and doesn't match the resolution of the Main Camera
Reproducible with: 2018.4.30f1, 2019.4.17f1, 2020.1.17f1, 2020.2.1f1, 2021.1.0b1
Comments (1)
-
HeyItsLollie
Mar 16, 2021 02:12
I was the user who filed this bug, and I'm disappointed with this "Won't Fix" resolution. Its current behavior is obviously broken and functionally useless.
A note for anyone encountering this issue and looking for a codeless workaround:
1. Create a Canvas with its "Render Mode" field set to "World Space".
2. Create two cameras with identical settings. (Transforms, Camera FOV, etc)
3. The first camera is your UI *Render* camera. Set this camera's "Target Texture" field to your desired render texture.
4. The second camera is your UI *Event* camera. Apply this camera to your Canvas' "Event Camera" field.This solution was taken from the original Unity Forum thread reporting this bug. (Post #11 by CptOblivion)
https://forum.unity.com/threads/canvas-raycast-hitbox-doesnt-match-screen-resolution-when-using-camera-with-render-texture.1014877/
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
- [Remote Config] PreparePayloadWithConfigType function is looking for camelCase property names, when the JSON objects are using PascalCase naming
- UI Builder Viewport's Tool Gizmo has deadzones
- SpriteShapes are rendered using multiple draw calls when the SRP Batcher determines their nodes are incompatible in a specific project
- UI Toolkit Debugger "Pick Element" selects Scene view panel when trying to select a world space UI element in the Scene view
- MSAA warnings are thrown when custom post-processing is used and the Scene contains transparent GameObjects
Resolution Note (2021.2.X):
To support this the mouse position needs to be converted between the spaces (world and render texture). This is not something we support natively but can be done manually but having a custom BaseInput that will convert the mouse position.