- Home /
How to scale the image through scripting so that the height of the image will be equal to the height of the screen and the width of the image will be scaled with the same percentage?
Any help would be very much appreciated.
Look at
Screen.Width
Screen.Height
Camera.main.ScreenToWorldPoint
SpriteRenderer.bounds.size
transform.localScale
Answer by watercat · Feb 05, 2018 at 05:12 PM
i have the options for canvas screen size if don scripting if need scripting i dot know haw to changes options or this size
I know how to do that. But I want to know how to do it through scripting. Thanks for the response though!
Provided the image is big enough to scale downwards, you can maintain the aspect ratio of the image with the height & width properties of the Screen class.
Answer by spokrock · Feb 05, 2018 at 06:11 PM
Provided the image is big enough to scale downwards, you can maintain the aspect ratio of the image with the height & width properties of the Screen class.