Set element dimensions to fill different screen sizes


Is it possible to scale an element (for example image) to fill the entire screen in different screen sizes like mobile tablet etc.

At the moment what I did was get canvas size by and resized the element height and width according to each device however in some devices it does not fill the screen completely.

My element is inside a 2d screen and anchored to the center pivot.


Hi @nasjarta,

Check this post, it discuses that:

1 Like

With image fitMode, you can now do this more easily.

Set the image element to anchor to all 4 corners of the screen and set the fitMode to ‘cover’ which will cover the area of the element bounds and keep aspect ratio: Release v1.21.61 · playcanvas/editor · GitHub

1 Like

Thank you it worked!