kugorang
kugorang

Reputation: 170

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.

Upvotes: 5

Views: 2908

Answers (1)

Lhamed
Lhamed

Reputation: 39

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

Upvotes: 0

Related Questions