Changing UI Image’s sprite, preserve aspect ratio is checked but not working. Version: Unity 2019.1.0f2
What happened
I updated to the latest software update for Unity which is Unity 2019.1.0f2.
Before when it was version 2018.3.12f, the UI Image’s sprite changes normally. But now when I have updated it, it doesn’t regain its aspect ratio and gets stretched.
When the sprite changes on the UI image, the aspect ratio/width and height changes for the image and when you go back to the original image, then it becomes stretched or compressed.
I thought it was because I updated my game Unity version but I reproduced it on a brand new Unity project and it is doing the exact same thing.
How I reproduced it:
Code in Sprite[ ] and Image.
Code to change the sprite image to the next image in the sprite array.
Have a button to cycle through the images.
Run game.
Press button multiple times.
When it is cycled back to the first image again, it is now stretched or compressed and aspect ratio doesn’t go back to its original size.
This bug has only been happening when I updated to the latest version Unity 2019.1.0f2 from 2018.3.12f.
I got similar issues on some UI sprites when changing them by code. Changing them manually via inspector fixed them temporarly, but each time I changed them via code, they broke again. (stretch weirdly or else).
Although, it didn’t happened on every image. In my case the stretch issue happened only on the first image of an array.
At other time, there was an other UI image with button, and the image was cut in half once clicked, like the rendering of the quad didn’t completed.
I sadly can’t reproduce that on a blank projet (I tried without success), and can’t submit my 12 gb’s project either for bug report.
(No special shader used. I’m working with latest LWRP on 2019.0.f1. With different types of canvas (worldspace, overlay…))
Same issue here when updating from Unity 2018.2.12f1 (64-bit) to Unity 2019.1.0f2 (64-bit).
I did nothing else but updating unity to the latest release.
Moreover, the “Shadow” effect is also broken with sprite randomly being croped and render weirdly (in gray) as you can see in the following image:
I am having a similar ‘random streching’ issue with my UI images after updating, but I seem to have found a temporary fix.
Select your sprite in the inspector, and change Mesh Type from the default “Tight” to “Full Rect”
They have a bug on this : sizeDelta broken on Unity 2019.1.0f2
All these problem are related to this issue.
The funny thing , is that this bug has been reported the 3 april and they have released this version the 15 april without fixing it … bravo !
As always, they run too fast and release a broken version even with a bad poll result …
Anyway, to sum up 2019.1f2 isn’t production ready for UI. It kills existing projects (including my complex UI animations, some of them are awefully broken now, like scales and positions became a mess, directly in editor, without even play mode, never happened before and it’s been years ).
Updated to 2019.1.1f1 and still experiencing the same thing :(. Fingers cross for the next one, I can’t continue to do any game dev anymore with Unity since a lot of my stuff relies on this as well.