Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

Simple question: Asset bundles for static level geometry?

Discussion in 'Asset Bundles' started by dgoyette, Dec 21, 2018.

  1. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    1,667
    Hopefully this is a pretty simple question. I'm planning to implement Asset Bundles soon, and I want to make sure I understand the scope. My original understanding of asset bundles was that it was the alternative to the Resources folder for loading dynamic objects. Resources, as I understand, are all loaded when the game started up, while Asset Bundles can be loaded on demand. And while I plan to use Asset Bundles instead of Resources for dynamic objects that aren't used in every scene, I'm not clear on whether there are benefits, or any point, to using asset bundles for non-dynamic objects.

    In my game, the player passes through many different areas, each of which has distinct models and textures. Most of these things are "static", things like walls, furniture, windows, and other level geometry. These objects aren't instantiated at runtime, and they're not in my Resources folder. So my question is, do these kinds of objects belong in an Asset Bundle, or is Unity smart enough to release these objects from memory as the player moves from scene to scene?

    Let's say the player finishes a level in "Area1", then proceeds to "Area2", which is a new scene with completely new objects in it. Assuming I don't have any asset bundles, will all of the static models and textures from Area1 be unloaded automatically upon switching to a scene that doesn't contain any of those game objects? Or will they stay in memory, resulting in the game taking more and more memory and resources the longer the player plays?

    My optimistic plan for Asset Bundles is to only include content that is loaded dynamically via Instantiate. I would prefer not to have Asset Bundles for every last object in the game, unless that's necessary from a resource perspective.
     
  2. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,183
    Look into Addressables on Package Manager.
    At least that's what I'll be using.
     
  3. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    1,667
    Thanks. I'll look into that. A quick scan through the docs still leaves me wondering about whether addresses are only for objects loaded at run-time. The docs state "Address: Identifies an Asset for easy run-time retrieval." So, for something like a set of stairs, which are a static object in one level, but aren't present in all levels, would such an object be addressable? Or is Unity smart enough to release the memory used for the stairs when I unload the level containing the stairs?
     
  4. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,183