unity 2018 pixel perfect Camera , can i zoom in and out? - unity3d

Two questions the first how to zoom in and zoom out ? and why i have that red line in some resolutions is it a bug or a problem (i tried reimporting the package and recreate the project but nothing new) ?

It's about resolution and aspect ratio.
I see you are using an asset for this "Pixel Perfect Camera". If you want to zoom in and out you need to make sure you are staying in line with the original supported resolutions (and the aspect ratio).
On your camera settings the "Reference Resolution" is 320x180, on the error it says you're in "485x279", so it seems your project is in 16:9 (aspect ratio).
20*16 and 20*9 = 320x180. Keep your resolution in line with your aspect ratio. Simply put, you need a multiple of 16 for width and of 9 for height.

Related

How to set screen resolution in unity and then scale to fit window size

Trying to get Gameboy resolution which is 160px x 144px in unity and then the game will scale up when in full screan with bars around the side where the aspect ratio doesn't fit. But it still only has 160 "pixels" just scaled to take up however many pixels it takes
You could start by reading the documentation file on "Resolution and Presentation"
here is the link: https://docs.unity3d.com/Manual/class-PlayerSettingsAndroid.html#Resolution
and this forum page also seems to be helpful:https://forum.unity.com/threads/target-dpi-vs-render-scale-vs-resolution-scaling-fixed-dpi-factor-vs-setresolution.1076789/
Now based on these two I would consider this to be your solution:
Go to Edit > Project Settings > Player (on the left list) > Resolution and Presentation
once you are here find the Resolution Scaling Mode option and set it to Fixed DPI as shown in this Image
Once you do that you get the option to choose a number between 30 to 1000, which you would decide based on the output screen you target. If the number you set is lower than the screens native dpi, your game will upscale and by the same reasoning, I would say it would downscale if you set it higher than the native dpi of the target screen. I am not 100% sure this is the solution to your problem, but I hope it sets you up on the right direction.

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 art is blurry

For some reason, I can't get these tilemaps to come out like they were created in Unity...
The pixel art is imported to Unity from Tiled.
The pixel art in Tiled:
The same pixel art imported to Unity:
Does anyone have any idea how I can fix this?
Thanks in advance!
As requested, the sprite import settings:
Posting my comment as an answer after all.
As I suggested, one way to get rid of blurring is to set the "Filter Mode" of the sprite to "Point (no filter)" instead of "Bilinear" or "Trilinear"
Here you can see the difference between bilinear and point filtering.
If that doesn't help, try messing with the quality settings in the Sprite Import.
Increase the "Max Size" and maybe disable "Compression" or increase the quality of the compression.
Here you can see differences between the different compression qualities, ranging from "Low" over "High" to "None"
You can also try to increase the "Max Size" value for higher quality sprites. It scales the dimensions of your sprite to not exceed the specified value. If your sprite sheet is already smaller than the "Max Value", increasing it will have no effect though.
The next picture shows the differences between Sizes 512, 256, 128 and 64 for a Sprite with dimensions 423 x 467
You can see that sizes above the dimensions won't have any effect, whereas smaller values will scale the sprite down, decreasing its visual quality.
Usually fiddling around with those values should help making your sprites look sharp and not blurred anymore.
EDIT:
As #NikaKasradze pointed out, there are also default quality settings you can try. Go to Edit > Project Settings > Quality
The matrix on top gives you a selection of all current quality levels for the Editor itself as well as all build target platforms. The green tick shows what currently is selected as the default quality. You can also set the "Texture Quality" which defines the overall texture resolution in your project. You can choose between "Full", "Half", "Quarter" and "Eight Res". You should choose "Full Res" for your current default settings.
Considering you already changed the filtering from Bilinear to Point (no filter), the issue may be that Unity compresses your texture by default. This is likely if it is a POT texture (Power of two resolution).
You can override this for individual platforms at the bottom of the texture's import settings. Select RGBA 32 bit if you need the alpha channel (transparency) or RGB 24 bit if you don't, to get your texture uncompressed.
And don't forget hitting that Apply-button! ;)
If this doesn't help, could you post a picture of your import settings?
Also, what data type is your image?
EDIT:
After the import settings screenshot has been added, it seems to me the issue lies in the SpriteMode settings.
As far as I understand, the image used is a Spritesheet in form of a tilemap. Therefore the SpriteMode should be set to Multiple.
You can then click on the Sprite Editor button and cut the sheet into individual sprites using the Slice function (now separate, as of Unity 5.6).
You probably want to use the Grid - By Cell Size method, which is basically how this is handled inside Tiled.
You also want to adjust your Pixels Per Unit setting to match the resolution of your tiles (for pixel-perfect results).
I had some issues with blurry sprites and I was able to fix it by changing the resolution of my sprites in an image editing software. The resolution was 576x352 and I changed it to 512x512 and that fixed it. I think its best for Unity that images are square and have a resolution that is a power of 2 as often as possible (for example 512 = 2 ^ 9).
Make sure you disabled Mip Maps:
http://prntscr.com/eup3hd
After literally hours of tinkering, the only solution I could come to was to open photoshop and export the tilemap at 4000% its original size.
There is still some minor blurring if I zoom in but at least it isn't as bad as I demoed in my question.
I have tried everyone's answers here to no avail, I am left with the conclusion that it must be a Tiled2Unity problem (despite it never doing this before)
I will update this post if I find a solution...

Unity game scene is not in full screen on mobile

I'am having problem making my app be full screen on all device. on my device, w/c is a low end Jelly bean phone doesn't give me the right resolution I want.
Here is my desired output:
this is still in editor, resolution 1080px by 1920px in Portrait mode
here is the output on my device:
as you can see, you can see a blue part on the screen.
Thanks in advance.
It looks like your background is visible from behind your geometry, the aspect ratio of two screenshot is different. It looks like you designed the game in a 278x490 resolution (aspect 1:1.762) and displaying it in a 480x800 resolution (aspect ratio 1:1.666).
You should always design for the lowest possible aspect ratio, then you don't have this problem.
You have two solutions:
You should add some walls/roofs to make margins that will be visible on wider devices
You can shorten the length of the corridor by scaling the game field up so the width fits.

Image size incorrect in Unity

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/