Unity game scene is not in full screen on mobile - unity3d

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.

Related

How to scale unity UI for every device

I'm trying to make a level select screen for my game, but when testing the game build the ui isn't scaled that well
I'm currently using the Canvas Scaler with the following settings
These settings give me..interesting results to say the least
What the result is SUPPOSED to be is this
How am I able to do this?
There a few things that you should keep in mind while building the UI for different screens.
Have a target Aspect ratio. Generally it should be 16:9 for landscape and 9:16 for Portrait.
Make sure the reference resolution is in line with your target aspect ratio.
Set the Match option of canvas scalar to 0.5 to scale evenly. If you are sure the device aspect ratio will change in only one direction then set either height or width. For example a portrait game will scale only by height if you switch from 9:16 to 9:18.(0.5 has worked always for me)
Select the aspect ratio in the game window and set the Anchors of the UI to the corner of the UI element. That way Unity will know where the element should be based on Canvas size.
Here is a video that demonstrates it
https://youtu.be/08S1VGL9afg
First of all, use some custom resolution in game view instead of Free Aspect.
Then you could try adjusting Match with Height or width to 0.5.
In some case, you have to adjust custom anchors using these little guys
If you want to absolutely preserve aspects, use this option on Image component.

UI designing for multiple resolution in Unity

Hi I am really new to Unity development.I have a canvas with following structure
Inspector for all the UI elements are as below
For canvas
For Panel
For Inner Button
I am checking this on my iPad pro 2020.Followings are the results.(The + button inside the panel). My question is the "+" button and panel's aspect ratio is different when changing from portrait to landscape. How can I fix this issue? Thanks in advance.
Portrait
Landscape
If you choose a canvas scaler type (width or height), should change dynamically with W/H ratio your device aspect ratio calculation as float value, also this value are related your device screen orientation. So you need to calculate seperately for portrait or landscape orientations. Differently you could use match mod with shrink and set value to minimum pixel ratio your sprites.
However, in some cases, you may need to create compatible image files in different resolution modes while designing for tablets.
These methods gives you a immutable screen visuals...
Also, if you haven't read it, please read this thread and the related instructions.
Multi Resolution

How do i fix the layout problem in unity?

Im trying to build a replica of the game 'Breakout'.
when i build and run the game in unity it looks good and everything id the correct scale but when i build and run the project on my laptop all the elements change size and some of the elements dont change size and i am not sure if i have done anything wrong or if i have forgotten to do something to stop it from changing.
This is what the game looks like in the unity editor when playing the game:
And this is what it looks like once i build and run the project on my computer:
My resolution is set to stand alone.
is there a way to get it to look like it does in the unity editor when i build and run it on my computer because that is what its supposed to look like.
These days, there are many different screen sizes, and resolutions.
My favorite solution is to use a reference resolution that can expand but never shrink. This allows you to have a safe zone that stays consistent across different screen sizes. For a generic case, you would use 16:9 aspect ratio, with the resolution of either 1280x720 or 1920x1080.
In Unity, on your canvas, modify the Canvas Scaler such that UI Scale Mode is set to Scale with Screen Size. Add your reference resolution, and set the Screen Match Mode to Expand.
In the Game tab you can preview what 16:9 looks like. You can try out other aspect ratios or resolutions.
For example, the iPhone 11 has a much wider resolution, so it expands horizontally. It's up to you to design your UI in a way that makes sense. You can either keep everything in the safe zone or align elements to the corners of the screen.

How to make responsible camera for multiplie resolutions?

I m working and some 2d game for mobile phones relate to chess, and I have a trouble with show board for different resolutions of mobile screens.
Here u can see how it must be on 9:16 resolution:
https://drive.google.com/open?id=1MFt-FtEtqkk7QWQC2oAtMBA0WAgOIV4h
And how it looks on smaller screen:
https://drive.google.com/open?id=11WLYZwHEa9ijXbekzUbE5ZbjbEnjZ6Lb
How can I protect my chess board from cropping?
Answer: it depends on how you want it to look.
If you just want it to fit perfectly horizontally, you need to perform 3 steps:
Evaluate the width of the Sprite (with Sprite.bounds)
Evaluate the width of the current screen (with Screen.width and using the main Camera)
Scale the Sprite to fit the screen
If you are using UI elements, you can do the same thing but you won't need to use Camera, just scaling according to the Screen width (look for RectTransform.deltaSize to give you the size of a UI element).
If you are using UI, also consider using layout groups, they help you with fitting the content to screen size.
Anyway, in a device with small width, maybe the table will get too small and you might have to think about better options to display the board instead of just scaling with screen width.

OpenGL ES : getting a fixed size for an object

I have an open GL ES (1.1) scene with many 3d objects and a "player" model. I'd like the player to have the same pixel size, regardless of the screen orientation on an Android phone or Iphone.
I'm not using glOrtho or billboards. That's a perspective 3d scene, but I just want the objects to have the same size in both screen orientation. Currently, if I rotate the phone, I keep the same aspect ratio but the scene "zooms out" in landscape mode.
I suspect that I have to play with parameters to glFrustrum to get this; but can't figure out yet how to do it.
So any ideas are welcome!
Thanks
You will need to change the aspect ratio when the device is turned to go from a the otherwise the size of the objects are going to change. THink of yourself looking out through a window, the objects on the other side of the window are only going to be the same size if you don't change your distance from the window (i.e. zooom in and out), when you "turn" the window sidewayse, the aspect ratio of the window changes (the metaphor is starting to not work).
If you draw a square in the view with the side length being the short side of the screen, then you should still have a square when you turn the phone sideways, still covering the same area on the screen.
Things will probably be easier to calculate if you use the code from gluPerspective. You set the aspect ratio to the actual aspect ratio, fix the fovy for the first aspect ratio. You can then use what would be fovx for this aspect ratio as the fovy for your rotated view.