Search Unity

Unity UI Changing image sprite from script is faulty in 2019.1.0f2 (Case 1146947)

Discussion in 'UGUI & TextMesh Pro' started by chanfort, Apr 17, 2019.

  1. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    603
    I just noticed that there is a bug in Image when sprite is changed from script. This is only happening when there is Outline or Shadow component attached as well with the Image component. The image becomes faulty after two flips.

    Reported a bug with case number 1146947 and a small project which includes assets only needed to reproduce the bug.
     
  2. Urishizu

    Urishizu

    Joined:
    Sep 24, 2016
    Posts:
    117
    I just upgraded and I'm also having this issue. It's essentially broken large parts of my UI. Is there a workaround for the time being?
     
  3. AvatarNick

    AvatarNick

    Joined:
    May 8, 2018
    Posts:
    7
    I am having an issue with this as well. It has broken my path finding system where sprite arrows are used to show path movement. I am glad that we have presumably identified this as a Unity bug, I spent 8 hours debugging this today to no avail.
     
  4. ProtonOne

    ProtonOne

    Joined:
    Mar 8, 2008
    Posts:
    406
    Nicola-Patti, DgoodingIndi and Mest like this.
  5. Urishizu

    Urishizu

    Joined:
    Sep 24, 2016
    Posts:
    117
    Is there any news if an official fix for this is incoming and when that will happen?
     
  6. chanfort

    chanfort

    Joined:
    Dec 15, 2013
    Posts:
    603
    Didn't got any particular news. I got in my ticket mentioned that this issue is already known and is related with 1143135. I ended up just disabling Outline and Shadow components in order to prevent code change at the moment. When these components are disabled, it works fine. And once it gets fixed, I will enable them again.
     
  7. Urishizu

    Urishizu

    Joined:
    Sep 24, 2016
    Posts:
    117
    I just went through and changed all of my .sprite sets to .overrideSprite and was able fix the issue (with shadows intact) everywhere.
     
  8. carsonherrick

    carsonherrick

    Joined:
    Dec 19, 2016
    Posts:
    3
    My strange behavior is this:
    Using straight Sprite Renderer (not inside an Image). Everything works fine in the inspector. But, if I change the Sprite from code while running the game, nothing happens. Only, when I stop the game, my changes take effect and the new sprite is the default in the editor.
    Also, my Sprite Renderer components are on objects inside a prefab. I might break the prefab, to see if that helps.
     
  9. telica77

    telica77

    Joined:
    Aug 27, 2017
    Posts:
    6
    I don't know if my issue is related, but the alpha component doesn't work on my UI images since upgrading to 2019.1. Changing the alpha value of the UI image does nothing in play mode and device. Script is changing alpha, to fade a UI image, nothing happens. I change alpha of the image manually in play mode, nothing happens. I can fix the problem my making it not a child of the overlay canvas, so maybe something is wrong with overlay canvas? My image has no outline, just a few custom scripts attached to it. Everything worked fine in 2018.2. Please see screeshot, see how the alpha is 0 and the image is still showing? It also happens in other parts of my game with UI images. If anyone has any ideas please let me know.
     

    Attached Files:

  10. ardiawanbagusharisa

    ardiawanbagusharisa

    Joined:
    Oct 26, 2015
    Posts:
    8
    Similar problem to mine.
    If I change the sprite of Image UI in canvas manually by drag-and-drop, it's working just normal. But when I make the alpha 0, and then change the Image's sprite and make the alpha become 1, somehow, the sprite is still transparent even when the Image's alpha is already 1.

    I'm using Unity 2019.1.0.f2
     
  11. Nicola-Patti

    Nicola-Patti

    Joined:
    Apr 8, 2016
    Posts:
    2
unityunity