Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Sprite Atlas Packer V2

Discussion in '2020.1 Beta' started by mahdi_jeddi, Jan 29, 2020.

  1. mahdi_jeddi

    mahdi_jeddi

    Joined:
    Jul 18, 2016
    Posts:
    245
    Are there any info about this new sprite packer mode in editor settings in 2020.1a20? I can't find anything on the forums or on the manual or internet. All it's doing now is to disable the atlas controls and act as if the packing is not enabled for editor.

    I would love to know what this option does and what are the improvements.

    Screenshot_1.png
    Screenshot_2.png
     
    DhiaSendi, ROBYER1, sama-van and 2 others like this.
  2. TJHeuvel-net

    TJHeuvel-net

    Joined:
    Jul 31, 2012
    Posts:
    834
    Odd they call it v2 because this seems to be the third iteration. First we had sprite packing tags, then sprite atlas assets.
     
  3. sama-van

    sama-van

    Joined:
    Jun 2, 2009
    Posts:
    1,733
    Interested as well :)
     
  4. Kolyasisan

    Kolyasisan

    Joined:
    Feb 2, 2015
    Posts:
    396
    In case if I'm not mistaken, Sprite Atlas V2 has one particular improvement over Sprite Atlas V1 regarding asset bundles and, inherently, addressables. Sprite Atlas V2 will not duplicate the sprite texture inside a bundle (so only the atlas texture is included) provided that
    1 - the original sprite texture asset is not explicitly included
    2 - the sprite atlas is explicitly included in one of the bundles to avoid atlas dupes
     
    mahdi_jeddi likes this.
  5. Oshigawa

    Oshigawa

    Joined:
    Jan 26, 2016
    Posts:
    362
    Will it be possible to just load the whole atlas and sprites in it via addressables without all the array and GetSprites stuff?
     
  6. mahdi_jeddi

    mahdi_jeddi

    Joined:
    Jul 18, 2016
    Posts:
    245
    If I'm not mistaken the old system duplicated only sprites' info in very small sprite files with the same names and not the whole sprite with texture. I'm saying this from checking the file size report after the build: all of the sprite files were a few hundred bytes instead of multiple hundreds of kilobytes in our case. But any improvements to this system is really appreciated.
     
  7. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    632
    SpriteAtlas V2 is an experimental version to address the following:

    1) Support for Cache-Server/Accelerator. (SpriteAtlas v1 maintained its own local cache in Library\AtlasCache but V2 uses Importer workflow and hence data is stored/cached in the regular artifacts folder thereby also supporting Cache-Server/Accelerator).
    2) As SpriteAtlas V2 uses Importer workflow and the source asset never gets modified(unless modified by user through Inspector of course).

    Also the following are known limitations :

    1) Adding a folder as packable is not yet supported in SpriteAtlas V2.
    2) Packing SpriteAtlas V2 is immediate (V1 defers packing to EnterPlayMode/Build time).
    3) Scripting support for V2 is not added yet.

    We will address the above in the coming releases.

    More info here : https://docs.unity3d.com/2020.1/Documentation/Manual/SpriteAtlasExperimental.html
     
  8. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,188
    This does sound like some good improvements over the existing Sprite Atlas assets. Not entirely sure if the current one has some bugs or if my issues are caused by the design, but not modifying source assets really would be appreciated!

    Any news or timeline on this? Is scripting support entirely non-existent or only hidden somewhere in the API? I'd really love to create the new SpriteAtlasV2 asset from code during my automatic import pipeline.

    PS: I worked through some of the internal code and it looks as if I got it working to add sprites to the v2 atlas asset during the import process. I don't really understand why the following is required, but I needed to use InternalEditorUtility.LoadSerializedFileAndForget.

    Code (CSharp):
    1. SpriteAtlasAsset atlas = null;
    2. var array = InternalEditorUtility.LoadSerializedFileAndForget(path);
    3. if (array.Length != 0)
    4.     atlas = array[0] as SpriteAtlasAsset;
    5.  
    6. if (atlas == null)
    7.     atlas = new SpriteAtlasAsset();
    8.  
    9. // Don't add duplicates.
    10. var spritesArray = sprites.ToArray();
    11. atlas.Remove(spritesArray);
    12. atlas.Add(spritesArray);
    13.  
    14. var settings = atlas.GetPlatformSettings("DefaultTexturePlatform");
    15. settings.maxTextureSize = 4096;
    16. atlas.SetPlatformSettings(settings);
    17.  
    18. // Since the SpriteAtlasV2 is an imported asset, we cannot simply edit
    19. // the loaded object representation. Instead, only a fresh instance
    20. // will serialize correctly (e.g. AssetDatabase.CreateAsset). However,
    21. // this would change the GUID each time, which the following call doesn't.
    22. InternalEditorUtility.SaveToSerializedFileAndForget(
    23.     new Object[] { atlas }, path, allowTextSerialization: true);
     
    Last edited: Nov 26, 2020
    waishan, DoN2kcz and wuGor like this.
  9. LucidSloth

    LucidSloth

    Joined:
    Mar 9, 2021
    Posts:
    5
    Will SpriteAtlas V2 be back-ported to Unity 2019?
     
  10. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,571
    It's very very unlikely. Updates to Unity 2019.4 LTS will only cover usability fixes aimed at improving the stability of the product to enable users to ship their projects. It will not cover the introduction of new features.
     
    LucidSloth likes this.