'Scale UI buttons and images with screen size

I ma developing a game for unity and i want to be able to scale my buttons and UI elements to fit different screen sizes. Please how can i go about this? I have tried scale with screen size and it doesn't seem to help me. Is there a script i can use for this?



Solution 1:[1]

You will want to use a canvas scaler for this.

Canvas scaler in inspector

You simply attach this object to your canvas parenting your UI elements and it will scale them acordingly.

You will also want to make sure your UI elements are anchored correctly so that they stretch with their correct anchor point.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jay