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

uGUI

-

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

  1. 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.

Comments (1)

  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

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.