Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

How to handle 10,000 sprites worth animation ? (Resources vs AssetBundle)

Discussion in '2D' started by shubhank008, Aug 30, 2019.

  1. shubhank008


    Apr 3, 2014
    I created a 2d project which uses lots of sprites (10,000~) for animation of 7 characters (well each character has 12 sub-animations).
    When I initially exported the project for iOS (2GB~) and tested it on my ipad, the app crashed with "Terminated due to memory error" and I realized my app is using 12-13GB memory (atleast thats what Unity Profiler says in memory tab), even though I am using sprite atlas to club all images for each character and compress using ASTC.

    Memory profiler tab says textures using 10GB~.

    So my next approach was to try and load characters and their animations as and where needed (there are 3 parts/UIs), tried prefabs approach but seems just referencing prefabs in scene loads them the same as activating/deactivating objects (what I was doing).

    So far it seems using either Resources or AssetBundles is my option, I was leaning to use Resources but Unity docs seems to hate it and favor AssetBundles, fine.

    Used assetbundles, created a prefab for one of the charas, saved it and exported it as a assetbundle (500MB chunk compressed, 1.3GB uncompressed).

    Now thing is, I tried using LoadFile and LoadFileAsync both methods (I saved my bundle in streamingassets directory) and both methods are blocking main thread/UI and taking upto a minute or even more to load the asset prefab, furthermore breaking any script links or references it had.

    I am on a fairly powerful PC and whole unity project is working from a SSD.

    Feeling quite depressed not being able to make it work anyhow smoothly since yesterday now.

    Any help would be appreciated.

    PS: This is not a game but a semi-app
    Frames are 512px, they are 100-200KB on disk but in Unity or when loaded they are in MBs. They are NPOT so I am using a Sprite Atlas to make them POT and compress using ASTC. Their total size when in sprite atlas seems to be just 1-2MB total.
    Each animation is 8fps and contains 80frames~. So each character has 12x80 => 1000~ frames it needs for its complete set of animation.