Reputation: 360
I'm making a game on Unity, and here is my question:
So in UI, when I set an object's (like the title) Rect Transform to stretch, it loses aspect ratio as I change the screen size. But when I don't put anything, it shows too little on my phone screen. What do I have to do so it doesn't lose the aspect ratio but still stretches it according to screen?
Upvotes: 2
Views: 11389
Reputation: 11
make canvas UI scale mode to scale width screensize, keep reference resolution as width *height..recommended to keep height width and height so that it fit to screen size center,if possible make panel as parent and create all gameobjects into that,set layout element min to max width and height
Upvotes: 1
Reputation: 1601
You can use preserve aspect for images. For texts, you can use Best Fit option in the inspector(also adjust the max size according to your need).
Upvotes: 2
Reputation: 1866
I think what you're after is the Aspect Ratio Fitter component.
If you're trying to stretch the width to fit, then you'd use that component and set the Aspect Mode to Width Controls Height. Although, you'd need to work out the Aspect ratio you want to preserve (width/height).
There are some other Aspect Modes that might be worth taking a look at too, depending on how you need this to work - Fit in Parent being one that you could use to set the desired size in relation to a parent 'stretched' element, but keeping the aspect.
Upvotes: 3