# ScaleRectByScreenWidth\_Generic

Works well if your game has only 1 mode: landscape of portrait.

## How to use

Add this scirpt to element that you want to scale if resolution will be narrow.

<figure><img src="https://1613353771-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fygjewtla1W7kzTTIpGWq%2Fuploads%2FJ52CzffQWt1zKg90xpP0%2Fimage.png?alt=media&#x26;token=e3dc1ca1-901e-416d-8d2c-25b5daf19c69" alt=""><figcaption><p>Script in the inspector</p></figcaption></figure>

Scale Factor -> how fast we should scale down rect if user resolution less then Ref Resolution.\
Target Rects -> what rectTrasnforms we should scale down (should be only parent),\
Ref Resolution -> resolution from what rects will be scaled down (1080x1920 -> 9:16, so rects will scale down if user resolution will be lower then 9:16 by width),\
Always Update -> set <mark style="color:orange;">**true for tests**</mark> (in <mark style="color:red;">**production should be false**</mark> to not update rect scale every frame)
