Hi guys, I'm very new to the Unity UI system, and there's a few things I can't quite do for the moment, and I wonder if and how that should be done.
The project I'm working on would be for Ios/Android, and there's a lot of ratio sizes and proportions to take into account. The anchor system seems to do pretty well the job but there is a specific issue I can't fix for now : the background image.
I'd like the background image to fit the screen, without deformations. In other terms, it should be scaled so that the screen perfectly fits in the background, the backgound being larger OR higher than the screen depending on the situation.
It actually does the opposite : the background perfectly fits in the screen, leaving blank parts left and right or up and down, according to the ratio difference between the screen and the background. Of course I don't want blank parts.
Is it possible to do correct that behaviour so without going into coding ?
Thanks in advance.
Replies
There's a script called "Aspect Ratio Fitter" already available in Unity doing so.
- Select your background element
- add a component to it, search for "aspect ratio fitter" (script).
- Select the way you want it to fit amongst : width controls height, height controls width,
fit in parent or enveloppe parent
- Set the aspect ratio of your component
In my situation, I had to use "enveloppe parent".