Hello , Please i feel disappointed really , i can’t get clear solution or script or Tutorial for this problem for 10 days.
I build my game in resolution 1280 x 720 and it’s awesome. but if i change it by editor to any aspect ratio, the game is not good.
I did Maincanvas with Scale with screen size , screen space - camera.
i add sprite render for background and i write the script to make background the same canvas.
but i can’t make all game to be matching with all resolution aspect ratio.
please tell me clear solution for this question:
How can i make my game matching all Android Mobile Screen?
it’s 2D game , iam using Main Canvas and have a many photos inside it like child.
Screen Space overly ! not working because when i change aspect ratio ! the images is look different not not like good like 1280 x 720 !
i am beginner but i think it’s very hard i wasted time every day for 10 days and more than 10 hours per day in this issue ! i can’t get clear solution please help me !
its takes a while to get the hang of the Ui system, its not intuitive but its pretty powerful once you learn it.
so here it is in rough… you’ll have to learn about each thing mentioned, or find a demo somewhere that already does it, and copy the structure…
you already have screen space canvas that is step 1
next build your hierarchy inside that object,… say name it MainParent, and set its rect transform mode to expand to fit… this one will then match the size of your device…
now inside that… you want a bunch of photos… maybe you want then in a scroll window ?
so make another child object… ad a scroll component.
and inside that object… make another child, call it Container… add a layout component to the container… maybe a gridLayout Component
inside the container… make more objects, each with an “image” component for your photos… check the checkbox on those images to maintain aspect ratio.
setup the scroll component’s variable to point to your container.
That much may get you a grid of photos at correct aspect regardless of device.
More tricky stuff…
You may need to use a combination of the following 2 component types to get everything looking perfect…
ContentSizeFitter, and Horizontal, Vertical or Grid LayoutComponent
ContentSizeFitter is good to put on a parent, if you want it’s size to increase based on the child objects… ( possibly your scroll rect ‘container’ object)
LayoutComponents control how child objects fit next to each other… say for example you put a grid layout component on your Container. then all the photos would be put into that grid. you can set the size of each grid square in the layout component. …and the “keep aspect” ratio checkbox will keep your images for being stretched.
that should be enough to get you pointed in the right direction… learn those components and you’ll be set.