Search Unity

Image stretch change in 2019.1?

Discussion in 'Android' started by GuruGurra, Apr 26, 2019.

  1. GuruGurra

    GuruGurra

    Joined:
    Jan 18, 2018
    Posts:
    38
    In my project I have a UI Panel set to stretch to fill all available space. The Image component (sprite) of that panel is set from script and might be changed during the execution. When the device is rotated, the panel and image are expected to stretch and adapt to the new screen orientation. This has worked without any problems up to - but not including - Unity version 2019.1.

    In Unity 2019.1, the first sprite that is loaded (during app initialization) works OK when the device is rotated, but any sprite loaded later in the game will break if the device is rotated. The image is not stretched to fill the screen, but seems to stay in the original rotation and aspect. Please note that the panel stretches and adapts to the new device orientation, but the image does not!

    I have tried to add a separate Image object to the Canvas (instead of using the Image component of the UI Panel) but the result is the same; any sprite loaded after game initialization will fail to stretch to fill the screen when the device is rotated.

    Is this a documented (breaking) change or is it a bug?

    Edit: It is even worse than what I thought. It's not just a rotation bug, every Image size change is ignored once the sprite is replaced from code. It works OK in the editor, but on Android it's just a mess :(
     
    Last edited: Apr 28, 2019
  2. _met44

    _met44

    Joined:
    Jun 1, 2013
    Posts:
    633
    I have exactly the same issue after updating to 2019.1 :x

    Gonna try to repro in a new project and post a bug report.

    ps: and just to clarify, its not just android
     
  3. _met44

    _met44

    Joined:
    Jun 1, 2013
    Posts:
    633
    Hello again, just letting you know I've found a work arround, if you replace image.sprite = ... by image.overrideSprite = ... it'll show up properly and wont ignore the image size.
     
    Meheraj7 and flatsplay like this.
  4. GuruGurra

    GuruGurra

    Joined:
    Jan 18, 2018
    Posts:
    38
  5. eliGasious

    eliGasious

    Joined:
    Apr 7, 2015
    Posts:
    16
    Still helpful, thanks