- Home /
How to animate UI rect transform which works for all resolutions
My problem is that when i change the resolution my animation moves the UI element to a Set position the keys(Rect transform X and Y) in my animation have a set value is there a way to make the keys adjustable with screen res?
more detail:
I made this UI element(anchored in center) that starts at the center of the screen and moves to the top left corner of the screen(1920x1080). So when i now change the screen res (2560x1440) and play my animation my UI element is no longer in the corner. What i was hoping for when i created the animation was unity giving me some option to set a dynamic value that would change with screen res but i cant find it. The only other way i can see this working is trough script but i feel there has to be an easier way. I used unity in engine animation tool and typed in the values in the anim keys nothing fancy or different from a standard animation.
Answer by OneCept-Games · Jan 02, 2018 at 03:25 PM
Use the Canvas Scaler component, or move by Anchor value instead of "pixels". Unity CanvasScaler object
Very smooth very painless, I used the Canvas Scaler and set it to scale with screen size. I set the reference resolution to 1920x1080 and now my elements scale based on how big or small they are from the ref value. I didn't even have to do anything in my animation. Lets hope these change dose not cause problems down the line thank you @OneCept-Games.