Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I dynamically change the cell size of a Grid Layout Group component in Unity when developing for Android?

I am using Unity 2017.4.6f1 and I have a question about the cell size of Grid Layout Group among UI elements.

enter image description here

Currently, I was developing to 1080x1920 resolution, and I set the cell size to 200px and the spacing to 15px respectively. I set the resolution at 9:16 aspect ratio instead of the fixed resolution one day.

enter image description here This is the intended result picture from 1080x1920 resolution.

enter image description here This is an unintended result picture from a 9:16 aspect ratio.

How do you get your results to work as you originally intended for Android games? I would like to make the Cell Size correspond to all resolutions, just like the dp coding in Android development.

like image 916
kugorang Avatar asked Nov 07 '22 04:11

kugorang


1 Answers

How about Change "Canvas Scaler" - UI scale Mode in you scene as "scale with screen size".

here some reference in unity docs.

https://docs.unity3d.com/kr/530/Manual/script-CanvasScaler.html

like image 170
Lhamed Avatar answered Nov 14 '22 02:11

Lhamed