Search Unity

Bug Sprite Atlas is constantly changing serialized assets and logs warnings

Discussion in '2D' started by Xarbrough, Nov 25, 2020.

  1. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,188
    I set the project settings to "Sprite Packer Mode - Sprite Atlas V1 - Enabled for Builds", because I don't want anyone on the team waiting for sprite packing while importing assets or testing in the editor. At build time, I expect the sprites to be packed. I also expect that I don't hear from the Sprite Packer until the build.

    However, in our current project in Unity 2020.1.11, we constantly see this warning:

    Code (CSharp):
    1. Invalid sprite atlas asset encountered when matching atlas for sprite MySpriteName. Please repack all your sprite atlases.
    And I also see a lot of version control noise. When I make a change to a PSD file, the sprite atlas that references this file is changed like so:

    upload_2020-11-25_17-45-50.png

    And I see the mentioned warning. So, ok, even though I don't want to, let me hit the "Pack Preview" button on all atlases and go for coffee.

    Now the warning disappears, but now I have changed serialized data:

    upload_2020-11-25_17-49-28.png

    This result must be two different bugs, right? First, I shouldn't be forced to pack sprite atlases in the editor when the setting says "build only" and second, the "Pack Preview" button should only be a preview to check the layout and not actually be saved to version-controlled assets. Because otherwise, as it is now, we are causing constant merge conflicts and warnings for nothing.

    In my ideal workflow, the atlases are created during the automatic asset import pipeline, which we've set up. Here I can also add objects for packing. However, I want the sprite packing system to not save any packed data or muck around until a build is triggered. Once the build is over I also expect my version-controlled files to be clean. Sometimes I really get the feeling that only single devs are using Unity and it makes me sad because all of these features could be really great, saving me tons of time, if only they wouldn't get in the way of teams working together.

    I don't like to rant, so please give me some hope, that I'm doing something wrong or this is being fixed already! :)
     
    ROBYER1 and joshuagaebel like this.
  2. Meatloaf4

    Meatloaf4

    Joined:
    Jul 30, 2013
    Posts:
    183
    I seem to be getting some random resets on my sprite atlases as well, which is what it looks like is happening to you.

    I have no idea what the heck is going on here but my settings are set to "Sprite Packer Mode - Sprite Atlas V1 - Always Enabled"
     
  3. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    644
    If SpritePacker Mode is set to "Enabled for Builds" this warning should not happen. In SpriteAtlas V1, to ensure we don't repack the same sprites again, we add additional info when a SpriteAtlas is packed. It seems the change to SerializedData for a specific asset (PSB?) could be another bug.

    Agreed. Both are bugs and we will take a look as early as possible. Kindly file a bug report with a simple repro project.

    We have addressed exactly these in SpriteAtlas V2 (https://docs.unity3d.com/2020.1/Documentation/Manual/SpriteAtlasExperimental.html) which follows AssetDatabase workflow strictly. Please note that this is in Experimental state (please take a backup if you plan to give it a try) and we are hoping to leave in an upcoming Unity version. Will keep this thread posted.

    Sorry for any inconvenience caused.
     
  4. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,276
    I'm seeing this now in 2022 when switching platform. Was not fixed in spriteatlas v2?
     
  5. fleity

    fleity

    Joined:
    Oct 13, 2015
    Posts:
    345
    Funny that this has a recent answer. I am seeing this for a sprite that I generate in an asset post processor
     
  6. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    644
    SpriteAtlasV2 does not store states in meta data unlike V1. Could you please check Editor settings to verify if the project is indeed using V2.

    Could you please elaborate ?
     
  7. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,276
    Bug IN-67688
     
  8. fleity

    fleity

    Joined:
    Oct 13, 2015
    Posts:
    345
    Thank you for getting back to us on the issue, much appreciated :)

    I've seen your reply here too https://forum.unity.com/threads/inv...tching-atlas-for-sprite.1542080/#post-9628643 and I will try to create an repro project.

    To elaborate. I am creating a Sprite asset in an asset post processor which takes the UVs of a regular Mesh (from a fbx file) and builds a sprite from it which is then added to the import context. This works flawlessly except for that warning which pops up after the sprite has been assigned to the atlas and a new import of the fbx file is triggered. I suspect that the data of the sprite briefly gets invalid while it is recreated but the atlas still has some reference to it.
     
  9. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    644
    Thanks for submitting the bug report. I can reproduce the issue "Invalid sprite atlas asset encountered" warning. Will fix this asap and keep this thread posted. For now, please ignore the warning.
     
    andyz likes this.