Search Unity

Sprite.textureRect returning Rect.zero for SpriteAtlas-packed sprites?

Discussion in '2D' started by sama-van, Dec 16, 2020.

  1. sama-van

    sama-van

    Joined:
    Jun 2, 2009
    Posts:
    1,734
    Unity 2020.1.14f1

    Since I have insufficient privilege to that other very nice thread, let drop my comments there :

    - https://forum.unity.com/threads/spr...t-zero-for-spriteatlas-packed-sprites.583564/
    (Amazing thread by @Arthur-LVGameDev)

    To complete what is said in that thread, it works while disabling AllowRotation and TightPacking.

    If you make a single sprite and it's sprite.packed=FALSE, no problem with the sprite.textureRect.
    If you do the same with a packed sprite in runtime with sprite.packed=TRUE, the sprite.textureRect returns zero for all.

    If !Applictation.isplaying then sprite.texture still target the unpacked sprite.
     

    Attached Files: