How can I change a sprite width based on a screen width

Hi there! I’m making a 2D videogame for Android devices and iOS, and I’m trying to make a script for resizing my assets according to the different resolutions. First I tried using GUITexture, and I could change the width of my background based on the screen width, but everything moved and the trees where floating and things like that. Now I’m using planes, so everything stays at its place, but I don’t know how to adapt it to the width of the planes.

Thank you in advance!!

You should be able to use Screen.width and Screen.height to get the current screen pixel values, then use these to calculate a scale factor that you then apply to your sprites. Be careful to uniformly scale them though, trying to account for the width and height separately will likely cause deformation in your sprites. Also be aware that, depending on the actual resolution of your sprites, larger screens may cause some pixelization due to overscaling