Search Unity

Question Scaling issues when rendering UI to render texture

Discussion in 'UGUI & TextMesh Pro' started by dillonhowland, Jan 16, 2024.

  1. dillonhowland

    dillonhowland

    Joined:
    May 7, 2023
    Posts:
    1
    I am working on a pixel-perfect effect for the UI elements. The way it works right now is by rendering the UI to a render texture, and then having an overlay canvas display the render texture using a raw image.

    However, I have had some issues with the scaling of the render texture. From what I've noticed, the render texture doesn't scale with the resolution, and results in the UI remaining at the same size as the render texture (960x540). This causes issues because playing on a higher resolution such as 1080p results in the UI elements being in different locations than from what is being shown to the player on the overlay canvas. Is there a way to have it where my UI can retain its resolution but also be able to scale up so that the actual UI isn't different from what is shown on the render texture? I've seen threads about making a custom script that inherits from CanvasScaler and overrides the "HandleScaleWithScreenSize" method but I haven't seen any threads about that go into a lot of detail.