Search Unity

Unity UI Sprites inside SpriteAtlas with rotation enabled get rotated on UGUI but not in SpriteRenderer

Discussion in 'UGUI & TextMesh Pro' started by jose_10, Dec 29, 2017.

  1. jose_10

    jose_10

    Joined:
    Oct 1, 2015
    Posts:
    8
    Hi! I just came across this issue and I'm not really sure if it is a bug or an expected behaviour (but really annoying...).

    I'm using the new SpriteAtlas for the first time, and when you create it the Allow Rotation and Tight Packing options are enabled by default. The thing is that if I use this options and one of my sprites gets rotated, when I use it inside a UI Image component it gets rotated in play mode.
    It happens the same with the Tight Packing option, it will display anything coming from adjacent sprites inside its alpha content. There is a video showing everything just in case it is not really clear:
    https://drive.google.com/open?id=1d3XP4jsnxiI_xbtQdPbEY9nH3Ok4sCDH

    The strange thing is that this behaviour does NOT happen on the same sprite inside an SpriteRenderer component.

    Am I missing something? I really don't understand this behaviour, how am I supposed to place all my UI elements correctly if their rotation can change whenever I add any new elements to my atlas? Am I supposed to check any time my atlas gets updated if any element inside changed its rotation and check my entire game to rotate manually any UI image that gets affected? Not a really clever approach, if you ask me... And there is the TightPacking issue, which I have no idea how to get rid of that noise being rendered in my sprite.

    Any suggestions? Apart from "just uncheck these options" xD I mean, if they are available they are supposed to be useful, right?

    Thanks!
    Jose
     
  2. AlienMe

    AlienMe

    Joined:
    Sep 16, 2014
    Posts:
    93
    Just uncheck these options... :)

    The issue is that Unity UI always uses a quad for each sprite... So, it can only use square, non-rotated sprites.

    Sprite Renderer, on the other hand generates a mesh based on the non-transparent part of the sprite, with tons of triangles (not necessarily a good thing), but will let you use rotated and/or tight packed sprites.
     
  3. jose_10

    jose_10

    Joined:
    Oct 1, 2015
    Posts:
    8
    I understand, but I find really strange that this behavior is not mentioned anywhere in the documentation. Everyone wants to create an atlas for the UI, and these options are checked by default. If they can only be used in atlases used by Sprite Rendereres but not by UI elements, a little warning/explanation with graphical examples in the Sprite Atlas documentation page won't kill anyone..

    So, I assume this is completely normal and won't be fixed/changed on future updates, right?
     
    sunwangshu likes this.
  4. AlienMe

    AlienMe

    Joined:
    Sep 16, 2014
    Posts:
    93
    No idea, Unity will have to answer that.

    I haven't been able to use the new Sprite Atlas for production. In theory it replaces the old Sprite Packer (which is now marked as Legacy), but in practice, I've found it lacking. No support for Asset Bundles or Unity UI.
     
  5. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,267
    I have also found this a problem - rotation tight packing was also re-enabled when I upgraded a project from 2017 to 2018 so the issue came back!!
    Not having any warning or anything is bad - new users must be mystified!
    I don't know why the UI gets so little love...
     
  6. Nintenjo

    Nintenjo

    Joined:
    Oct 12, 2012
    Posts:
    8
    We use 2017.4.7f1 and 'Allow Rotation' on sprite Atlas assets does work the UI simple un-rotates the asset at run-time as you would expect.. However 'Tight' packing does not which is a real shame. It would be nice if Unity UI could use more than just a quad mesh and define a polygon mesh like SpriteRenderer would save huge amounts of wasted packing space on our UI texture pages.
     
    LouisHardlight likes this.
  7. erfan

    erfan

    Joined:
    Dec 21, 2012
    Posts:
    7
    In new Versions of Unity (2019.2) for sure, you can check the option: "Use Sprite Mesh" in the Image. it will fix the problem
     
    FuriousEX and halfdan87 like this.