Search Unity

Question Matching Sprite Renderer and UI Image Size

Discussion in 'UGUI & TextMesh Pro' started by Ghostbright, Sep 14, 2020.

  1. Ghostbright

    Ghostbright

    Joined:
    Sep 6, 2014
    Posts:
    10
    Screenshot 2020-09-14 17.47.46.png
    I have created a 64x64 pixel test image in an attempt to get the UI scale to match the world scale. On the left we have the asset rendered as a UI image on a canvas, and on the right we have the asset as seen through the sprite renderer.

    Despite my best efforts, I cannot get these two objects to match in size. The sprite's pixels per unit is set to 32. I'm not adjusting anything on the sprite renderer. I have tried tweaking all manner of factors on the UI canvas and image.

    To be clear, I am not looking to manually adjust the scale of each object. I just want to be able to set up the canvas so that the size matches world size and scales with device in the same way.
     
    NatsuD_123 likes this.
  2. NatsuD_123

    NatsuD_123

    Joined:
    Feb 19, 2019
    Posts:
    18
    Same here…!!
    Can anyone help! Please!
     
  3. NatsuD_123

    NatsuD_123

    Joined:
    Feb 19, 2019
    Posts:
    18
    I found this link on the internet, but this is not exactly what I am looking for (Partially).
    https://gamedev.stackexchange.com/q...alscale-to-resize-the-sprite-to-a-defined-hei
    i simply have a canvas image with x width and y height and a sprite renderer with the same texture as the image on the canvas, i want to scale the sprite Renderer, so it fits over the image on the canvas, but i don't see how to achieve that nor do i find anything on the internet by any means.
     
  4. jf065d

    jf065d

    Joined:
    May 28, 2018
    Posts:
    23
    I know this is an old thread, but in case anyone else comes across it: My issue was the "Size" of my Orthographic camera. I had it set to 5 instead of my intended 5.4. (5.4 x 2 = 10.8 for a 1080 screen height). Because my camera size is only affecting my non-UI objects, it was making them slightly larger than my UI objects.
     
    judy_unity83 likes this.