Unity2D UI Image sprite to fill frame
I have an UIImage of a frame 200x200, and a sprite of a frame 200x150, so if I set the sprite of the image to my sprite, it will stretch vertically to fill 200x200. I know I can use preserve aspect property to avoid stretching, and will have a "fit" render mode of my sprite, having edges from top and bottom. What I want is the "fill" render mode, where the sprite is scaled (zoomed) both horizontally and vertically to fit the 200x200 frame (aspect ratio stays the same, so no stretching). I wonder is there a simple property to get the desired effect, or it needs to be manually implemented?
Answer by idbrii · Apr 30, 2018 at 11:09 PM
If the frame is 200x200 and the image is 200x150, then you cannot make the image fill the whole frame without stretching. Maybe what you want is to add a background (like letterboxing) so the frame is filled?
I think you need to do that manually: add another gameobject above your image in the hierarchy and give it a black color and the same size frame.
Your answer
Follow this Question
Related Questions
Object reference not set to instance of an object? 1 Answer
Sprite Renderer and Image 0 Answers
Preserve top right position and relative size to screen 0 Answers
UI Image Cutout / Masking in spefic areas with sprites 0 Answers
Changing UI Image's sprite, preserve aspect ratio is checked but not working? 0 Answers