Getting my background to scale in a predictable way

I have an image that is 1217x601 (don’t ask why, I’ll find a different resolution for it at some point). But when I put this image on my game intending it to be the background for my scene it’s displayed with a huge margin around all sides.

In the image example here the screen size is 1207x679 so I would expect the graphic to crop on the top and bottom and not quite fill the width. Either that or it would scale to fit vertically and then leave a bigger gap on the sides. Either of those I could see being reasonable outcomes, however the results below are what I get.

Also note the inspector values on the right are those currently being used for the background game object.


Additionally, here are the camera settings for the scene

Any help much much appreciated!

Thanks

camera ortho size influences the coordinate system and changes the scale of all objects.

Is there a size, for instance 10, that I could set the ortho camera to that would cause 1 pixel to appear as 1 pixel on the screen? So that if I have a 800x600 image for instance, it would take up an 800x600 pixel area when the game is running?

depends totally on the size of the geometry. If you had 10, your geometry would need to cover 80x60 units in coordinate space, ie that’s the scale of your rectangle. I think.

Here’s a video that explains some things on how to work with 2D camera in Unity:

You can download the project files from here:
goo.gl/6oSzDx

I hope this helps :slight_smile:

Thanks for your replies. I am sad to report that they did not provide me with the answer I’m looking for, however I ended up just going through all of the 1-hour live training tutorials one at a time and finally this video did end up helping: Mini-Projects from the Recorded Video Training Archive - Unity Learn.

I’d love positive reinforcement that the conclusion I came to was the correct one though if anyone feels so inclined to indulge.

What I have decided the answer to the question is that I should avoid trying to concern myself with pixels as much as possible and instead rely on a combination of Unity Units, viewport points and world points to align and scale my game. What I ended up doing was not really caring what size my background was so long as it wasn’t too big or too small. It could be bigger than I need, just not inefficiently so. I then just made sure my background was big enough and the right aspect ratio (in this case 1920x1080, 16:9). At that point, I can choose my ortho camera size, although I’m sure there are advantages to just leaving it as the default so that’s what I did. Lastly, if my image was either too big or too small by just a smidge I could adjust the Pixels to Units property of my image. In my case none of these were necessary after I resized my background image to 1920x1080.

Appreciate any feedback!