βš™οΈScaleRectByScreenWidth_Generic

Used to adoptate UI elements on different screens

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.

Script in the inspector

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 true for tests (in production should be false to not update rect scale every frame)

Last updated