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
-
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
- The Scene View becomes gray and "NullReferenceException" errors are thrown when attaching the Unity Editor process to RenderDoc
- Memory usage rapidly rises when changing colors in the color wheel
- Physically Based Sky's Horizon and Zenith Tint Color Selection Bars don't have immediate access to color pickers
- EmptyAdditionalLightShadowmapTexture leaks from memory when URP quality level is changed using QualitySettings.SetQualityLevel
- Referenced ScriptableObject field does not get updated and cannot be set to "None" when there are no Objects of that type
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.