Hello in my unity project i have made 2 levels but when i build and run them on android they always scale upwards or downwards either the buttons were way too big or the main menu icon was really small.. i was wondering if there is any way change the scale or configure the look from the editor. Any help is appreciated.Here are some screenshots. http://kharief.imgur.com/all/ ( i want the paper to be the background and scale down the buttons)
You can change the way the Canvas scales in the inspector. You can either have the pixels set to a constant size, scale with the screen size, or maintain a constant physical size.
Related
I have few scenes in my project. I was able to center all of the other scenes. But i cannot center the main scene in my project. Its fine when it opened on a mobile device(probably because resolution matches i guess). but when i opened it in tablet(its an old tab "xiaomi tab 3") its always align to the right on the screen. I was able to center other scenes but i cant center the main scene to screen for some reason. project setting set as 2D and Expand. I also tried to use Control nod, canves layers, margine containers.. but nothing works. If someone can give any suggestions, Thank you in advance.
img1
https://i.stack.imgur.com/FJOHl.jpg
project
1920 x 1080
I have seen this problem, or similar, in windowed mode. I don't know if this is the exact case, but if it doesn't mess with your project, try full-screen mode.
If it's that, you can also take care of the window bar size (which is a problem because it can change from different devices), since godot will count its pixels too.
Notice that you're only having this problem in one axis.
Also, I think you could take a look into the Viewport Stretch Mode. It could mess your graphics depending of the intended result—but other projects won't even notice, so judge for yourself.
The viewport setting sets the root scene’s Viewport to the base resolution. The rendered output of the root Viewport is then scaled to the display resolution. [...]
The viewport setting is a better choice than the 2d setting when pixel-perfect precision is required, since primary rendering still occurs at the base resolution.
Support multiple devices
Scaling correctly for all devices could be an odyssey, so bon voyage.
This might be a dumb question but I'm using unity to build a double pendulum app and because not all screen sizes are the same the UI buttons get moved around and don't scale to match the phones screen size. I attached a few images to show you what I mean.
Notice how in the third image, the return button overlaps the other UI sliders. I think the issue is that the pixel distance from the top of the screen doesn't change given new orientation. Is there a way to keep the spacing proportional?
On your canvas object, set it to Scale With Screen Size then, set the Match property to 0.5. This way the canvas will scale with both width and screen height.
If you need more info about Designing UI for Multiple Resolutions, check here
Well in your parent cancas object in the inspector,the 2end setting there a a drop down. Click it than a magical setting scale with screen wil be ther.👍
I'm developing ios app for a service that already has android application.
I have psd files and png files corresponding android one.
But I don't know how to set image's size and coordinate as the same as android....
Is there a way to follow android's ratio constructively?
I'm just setting imageview by eye measurement...
By eye measurement, I calculated ratio, size(width,height) and coordinate...
I want to make images set as the same as the android's one.
I'm just using 'aspect to fit', that makes this problem less heavy but not perfect
Calculating everything manually will be horrible when you want to support multiple devices of different screen size. Use constraints if you want to scale the UIImageView to a certain ratio of another view.
Please refer to the auto layout guide at https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/AutolayoutPG/Introduction/Introduction.html
On Gideros I set the Logical Dimensions to 720x1080, with Scale Mode = Letterbox, and when I test it on the emulator with the same resolution it looks good, with no bars at the top and bottom or at the sides.
Then when I test it on a Sony Xperia T (720x1080 also) it shows a top and bottom black bar, with the navigation bar at the right side. It seems as if the navigation bar was interfering with the game's width, and so it loses width so the game will fit, ending up with the mentioned top and bottom black bars. Am I right? is that why I get those bars?
The problem also happens when I set the game's Logical Dimensions to 480x800 and change the images for that resolution. On the emulator works fine but on a 480x800 device it shows the same bars.
So my question is: Why am I geting the top and bottom black bars on my devices? Is it because of the navigation bar? How could I fix this?
PD: The game is on Landscape mode
Yes you are right
since onscreen "hardware" buttons does not count as part of the screen, the width then is smaller, thus you get the spaces.
(BTW you can change portrait to landscape in AndroidManifest to display buttons correctly)
More information on spaces and scaling
So you have a logical dimensions, for example: 480w by 320h (although they should be vice versa 320x480, (in logical dimension smaller always comes first) but thats another topic)
It means all your content must be prepared to deal with this dimensions.
But hey, not all devices have this dimensions right, so how to make it look similar on 800x480? You scale it up.
If the aspect ratio is the same (which is not the case in this situation as (480/320 = 1.5) and (800/480 = 1.66)) then you could simply scale up the scene with the one value for both width and height
But what if the aspect ratio is different
There are 3 ways to deal with it:
1) Stretching
We could stretch your width or height (what ever's ratio is larger) to fit the whole screen.
2) Cropping
scale by center to fill whole screen and crop out other what goes outside the screen
may not fit everyone but someone may use it.
3) Letterbox
It upscales to the maximal dimension of width or height, which fills the screen first, leaving whitespaces on other dimension.
What you choose depends on what you need to achieve, but my preference is Letterbox
And my suggestion would be, to prepare bigger BG graphics that go outside the screen (positioning them in the center of the screen using anchorpoint) and concentrate all the game on your logical dimensions.
Here's an example:
http://giderosmobile.com/forum/discussion/comment/13692#Comment_13692
Work with desktop simulator set with your logical dimensions if what is better for your, and change resolutions of the Desktop player to see how spaces appear and what BG pics may cover it
Another confusion may be, that by scaling in center, 0,0 coordinate is not in the left top position anymore (thus having spaces)
So what if I want to position object in the corner completely
Then as you did, ignore scaling by calculating the real offsets
http://appcodingeasy.com/Gideros-Mobile/Ignore-Automatic-Screen-Scaling-when-positioning-objects
Hope that helps :)
I have an iOS app that uses unique textured backgrounds (think of a game title screen or something) on each of the screens that I am trying to port to Android. On iOS they knew the resolutions and just designed the backgrounds around those. Obviously that isn't possible on Android.
What is the best way to put a textured/non-repeatable background into Android that works on various screen sizes and aspect ratios?
The solutions I have thought of so far are:
Fit the shortest dimension and allow the image to go off the edge of the screen for the larger dimension
Make the background image large and center it, then make it stretch out beyond the edges when the resolution is smaller than the image
Stretch the image to just fit (this is ugly and I'd like to avoid it)
Create a different version of the image for each resolution. (This seems way beyond the scope of what is possible for this project.)
As far as I can tell in Android, 1. and 2. aren't possible out of the box because background images set the size of the view to match their size (you can't tell it to just extend beyond the edges, please correct me if I am wrong).
What solutions would you use in this situation?
Use an (match_parent) ImageView to simulate back ground image. (By adjusting the scale type of imageview you can get the result of point 1,2)
http://developer.android.com/reference/android/widget/ImageView.ScaleType.html
Use 9-patch image. You can specify which part of your image can be stretched. For your case I suggest adding a small "margin" to your image, and make it stretchable using 9-patch. Only the margin will be stretched, maintaining the aspect ratio of your image.
android developer 9-patch
Create a different version of the image for each resolution.
As you're probably aware, Android can run on a wide variety of devices with varying resolutions and screen densities. To be fully compatible with all of them takes a bit of graphics work; you need resources for each possible screen density (and in this case, resolution).
For full details, see Supporting Multiple Screens in the Android developer documentation.
Unless something has gone seriously wrong in your development process, you should have the original files (e.g. .psd) to work with when creating these resources.