Changing UI Image's sprite, preserve aspect ratio is checked but not working?

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.

Help would be appreciated. Thanks!

2 Likes

Have you filed a bug report?

Yes I have, I was posting to see if anyone had a similar issue and if they had found a solution. Thanks.

When wait a fix? UI is broken.

Are you experiencing similar things?

Same problem for me on 2019.1.0f2
UI broken :frowning:
Waiting a fix

Have you filled a bug report? What is the number?

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…))

  • I didn’t had that issue before on 2018.3

I guess this issue is similar to our problem ?

3 Likes

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:

It was also working before updating

3 Likes

Yup. Outline, shadows, many effects on Image components are also (randomly or not) breaking them since 2019

Uh ? 'https://issuetracker.unity3d.com/issues/modifying-image-dot-sprite-of-an-existing-image-deforms-it"
from which issue this one is now considered to be a duplicate of ? There’s no way to know :confused:

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”

3 Likes

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 …

You have also this : PlayerPrefs not working on WebGL build?

And the best one : Editing inspector input field is broken with Unity 2019.1.0f2

All these bug from Unity 2019.1.0f2

So cool …

@karl_jones

1 Like

1148483
https://issuetracker.unity3d.com/issues/modifying-image-dot-sprite-of-an-existing-image-deforms-it

Change image.sprite in runtime:

Expected Result:

P.S It’s blocker for us :frowning:

1 Like

Thanks. Hmm that game looks an awful lot like one I’m playing at the moment :wink:

1 Like

Anyway, to sum up 2019.1f2 isn’t production ready for UI. It kills existing projects :confused: (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 ).

So… Can we have an ETA for a fix ? :slight_smile:

Also, please don’t forget my question ^^ :

"Unity Issue Tracker - Modifying "Image.sprite" of an existing Image, deforms it : from which issue this one is now considered to be a duplicate of ? There’s no way to know :confused: "

Is it a duplicate from that ? Which is himself a duplicate of that ?
Thank you and good luck for the debug :eyes:

This is the master bug https://issuetracker.unity3d.com/issues/image-color-cannot-be-changed-via-script-when-image-
type-is-set-to-simple

The bug has already been investigated and a fix exists. Once the team has landed the fix then we can begin backporting it and provide an ETA.

3 Likes

Thank you! this is great news, i hope this fixed in May.
Unity 2019 is cool!

P.S Try code 2288 to activate player unique skins in wardrobe :slight_smile:

2 Likes

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.

1 Like

It’s the same for me.
Also this bug https://issuetracker.unity3d.com/issues/playerprefs-dont-get-saved-in-a-webgl-build stop me to move foward …

I will check if this bug has been fixed in 2019.1.1f1
https://www.youtube.com/watch?v=PX6lEkuiT7U

2019.1.1f1 had none of the UI fixes backported / given ETA yet. I hope they’ll still land within this month though. It’s really game breaking :confused:

3 Likes