Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How do I load a sprite keeping it's native size right away? [Solved by myself]

Discussion in '2D' started by Ahab_, Oct 20, 2019.

  1. Ahab_

    Ahab_

    Joined:
    May 22, 2019
    Posts:
    59
    So here comes my super noob question:

    I have a camera in a scene with a custom resolution of 1600x900 in a 2D environment

    If I load a png picture of the same same size as the camera resolution through a UI Image component, and after clicking the "set native size" button it fits right away the screen as it should.

    But if I load the same png picture through a sprite renderer component, it's always smaller than it should be; to the point that I have to set manually the transform size to 1.12 both X and Y to fit somehow the screen as it should, but neither in a perfect smooth way.

    I didn't change any of the settings from the picture and it is loaded by default, so it has a sprite (2d and ui) texture type, sprite mode single, 100 pixels per unit, mesh type tight... and so on.

    Usually I check youtube tutorials and multitude of webs through Google in order to fill my needs; doing so I advance quite a lot for a newbie... but this current issue is really beyond me...

    So, what am I missing? How can I drag/load by component/load by script a sprite and make it fill the screen at it's native size keeping an aspect ratio of 1x1?

    Thank you for reading.


    SOLUTION

    Let me start with a big facepalm out of embarrassment....

    It turned out to be a matter of the Camera Size Field. After setting it from 5 to 4.5 all turned out as it should be. Now I remember I faced this issue past small project but it was such a little step on the way that I didn't take proper note about it and thus when I started again another little project I already forget how to deal with it. This time I will write it down properly...

    Well, at least I hope this thread on the .net helps any other noob who may search for the same issue eventually.

    cheers
     
    Last edited: Oct 20, 2019