Image size incorrect in Unity - unity3d

I have a Unity 2D project with a fixed screen size of 800x450 pixels.
I have imported a background image that is also 800x450 pixels.
When placed on the stage, the image only takes up half of the screen.
The scale of the image is set to 1,1. The Z position is 0.
Why is the image displayed too small? How can I display the image at the correct resolution?
Does this mean that I have to design all my game assets at 2x the required size? Or that I somehow have to set the scale for all imported assets at 2? What is the recommended workflow?
EDIT
I have added a screenshot of the camera settings:

I would trying making your camera orthographic, and set the size of the camera (not the transform) to be half the height that you would like it to be (225)
Also if you are looking for pixel perfect game. here is a pretty good article from Unity about how to make that work and it explains some of the camera aspect ratios and scaling
http://blogs.unity3d.com/2015/06/19/pixel-perfect-2d/

Related

How to properly scale camera feed and segmentation in Spark AR

I am working on a Spark AR lens where I need the camera feed of the user to be scaled down to about half the normal size. I have figured out how to scale the camera texture and the segmentation texture to fit my need.
The issue I'm having now is that the pixels around the edge of the newly updated scale get stretched to the size of the parent canvas as you can see in this image:
My patches can be seen here:
How can I prevent this pixel stretching from showing outside of the red square in image 1?
I simple solution would be to apply the camera texture to a rect, and scale the rect down instead. Another way to do this would be to create a custom shader, but that's more complicated.
Here's a working example that uses no patches and no code:

Why is my pixel art scaling wrong on other resolutions?

My pixel art assets all have a ppu of 32 and i have applied that to them all.
On 1920x1080, the resolution is fine, but most other resolutions the sprites pixels are squashed and stretched. I also have set the correct camera size using vertical resolution / PPU / 2). I have also used other formulas and they all give me the same camera size so i'm sure that's not the issue.
I have two moniters, one at 1920x1080, and one at 1360x768, and that moniter is where it scales wrong. Is there a way i can keep the pixels scaling the same across all resolutions? I have tried the pixel perfect camera and this doesn't fix my issue either.
https://imgur.com/gallery/Uf8YqNi Here is a sample of both resolutions, if you open them in a new tab and zoom in on the sprite you can see how tey get distorted in the 1360x768 screen.
Filter mode should be Point and compression None. If this doesn't fix it, then you should use Pixel Perfect camera. It will help you with the animations to be pixel perfect as well.
Window -> Package Manager -> Advanced -> Show preview packages -> 2D Pixel Perfect -> Instlal. Then you just add Pixel Perfect Camera component to your Camera.

Unity - 2D - Draw a sprite with it's "real" size

Is there a way to draw a 10x20px sprite always with 10x20px regardless of the resolution?
I don't mean to add it as a UI/canvas object, I want to be able to place it in the world and move it or move the camera.
thx for any help!
If using an Image component you can hit the Set Native Size button in the Inspector
Set the dimensions of the image box to the original pixel
size of the Texture.
In order to move it and place it in 3D it has to be a child of a Canvas with RenderMode = WorldSpace
Then also note the options of the Canvas especially the CanvasScaler -> Reference Pixels Per Unit value. It should be 1 in your case before hitting Set Native Size in the Image.
You can do that by setting the Camera ortographic size to the correct size. Try the 2D Pixel Perfect Camera package by Unity https://blogs.unity3d.com/2019/03/13/2d-pixel-perfect-how-to-set-up-your-unity-project-for-retro-8-bits-games/
The script in that package will automatically set your Camera ortographic size with provided parameters. If you want to manually set it, the formula is:
Camera ortographic size = vertical resolution / PPU / 2
Vertical resolution means the target vertical resolution that your sprite was designed for. For example, if your sprite is designed to look pixel perfect on 1600x900 screen, then the vertical resolution will be 900.
PPU means the pixel per unit, by default all imported sprites are set to 100.

Does Anyone know why my Camera size doesn't line up in with the Grid size on default???

So i've been having this problem for the last 2 days where my camera size isn't fitting my grid/tilemap size. Since i want to use tiles to make my game grid not fitting in the camera size would be really annoying because the tile would stick out of the camera view.i attached an image where you could see the grid not lining up with the camera size
Please check follow settings:
Check your Game window resolution setting, dose it be changed? If you are using Free Aspect, the camera size also be changed with Game window size in Editor.
Check the Feld of View setting of your camera.

How to size the camera in Unity (2D Project)

I'm working on a 2D project in unity and I'm having trouble getting the camera to the exact size I need. I would like the camera to be centered around a level I've already created, so I know exactly how tall and wide it should be, and where it should be centered. Where I get lost is translating these values to the properties of the camera. Any advice would be appreciated.
You can put more details about your problem.
Unity's camera rect is resolution depend. So you cannot set width and height of camera size. For example if you have resolution 16:10, camera rect will have that ratio, you can only change scale of that real resolution.