Search Unity

How to correctly utilise AssetBundles - Massive memory usage, 4x more than Resource folder

Discussion in 'Asset Bundles' started by Mowtine, Nov 6, 2021.

  1. Mowtine

    Mowtine

    Joined:
    Aug 17, 2014
    Posts:
    19
    I'm having a lot of trouble figuring out how I am meant to use asset bundles so they don't take gigabits of RAM. I am downloading my bundles with:

    Code (CSharp):
    1. UnityWebRequest request = UnityWebRequestAssetBundle.GetAssetBundle(url,version,0)
    2. AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(request);
    Then saving that bundle to a variable in a singleton for access during runtime: data_bundle = bundle; Then, when I need the images for my cards in the bundle, I load them all into a dictionary from the bundle like so:

    Code (CSharp):
    1. imageCache[imageName] = data_bundle .LoadAsset<Sprite>(imageName);
    And then when a card needs an image take it from the imageCache.

    I do the exact same thing with the Resource folder, the below two are the profiler for using the resource folder and using asset bundles when I load the same images into the cache:
    AssetBundles: (1.66gb textures)
    AssetBundlesSize.JPG
    Resources: (0.66gb textures)
    ResourcesSize.JPG

    Something is obviously wrong here, but I have no idea what it could be and why.
    Specifications:
    Android build - I have built the asset bundles for android as well (I assume they use the same import settings as Resources)
    Unity V: 2020.3.17

    What could I be doing wrong?

    Add comment
     
  2. Mowtine

    Mowtine

    Joined:
    Aug 17, 2014
    Posts:
    19
    This seemed to be caused by different import settings on my assets from my resources and the folder where the bundle was being made.

    I would still appreciate any advice on whether this is the correct method to use bundles.