Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

Addressables for all assets, or just runtime-instantiated assets?

Discussion in 'Addressables' started by dgoyette, Dec 21, 2018.

  1. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,113
    I asked this on the Asset Bundles forum (https://forum.unity.com/threads/simple-question-asset-bundles-for-static-level-geometry.601975), but I was directed here to see how this same question panned out for Addressables.

    The main question is whether it's necessary/preferable to make all assets in my project addressable, or whether that's only necessary for objects that are instantiated at runtime. From my other post:

    I have enough stuff in my game that ideally game objects used in only one area will only take up memory while the player is in that area. When the player moves to the next area, those system resources should be freed up. I think I understand how this works with runtime-instantiated objects, but I'm just not clear on whether I need to follow the same approach with static objects. In my example, I have a static staircase in one level. When the player leaves that level, and enters the next, do the resources for that staircase automatically get cleaned up? Or do I need to add those resources to an addressable, and manually load/unload the addressable when changing scenes?
     
  2. unity_bill

    unity_bill

    Unity Technologies

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    the answer to that question depends on your setup, though the short version is "either system will clean up what you tell it to clean up".

    Unity cannot determine when you want things unloaded based on a players movements. Your code has to do that. If you unload a scene because someone is elsewhere, everything in it is unloaded. so if you want to load & unload a full scene's worth of data at once, you can keep all that stuff (staircases) in the scene (levelX). As you load/unload that scene, it will load/unload the contents. In this instance, the scene itself could be included in the build directly, in resources, or in addressables.
    If you want to be able load portions of a scene (staircases), you need those chunks to be in Resources or addressables. I personally would recommend addressables.

    -Bill
     
    MNNoxMortem likes this.
  3. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,113
    That's very helpful, Bill. In my case, my game is probably fairly "simple", with the game broken up into many rooms, each of which is a scene. Complete scene loads occur fairly often, maybe once every few minutes, as the player leaves one area and enters another. I can see how some developers might want to streamline this, to avoid "loading" screens, using the addressables system to load what is needed, and unload what is no longer needed, for a more seamless experience. But I'm not aiming for that.

    So, it sounds like the following approach should be fine for me:
    • Most objects that just occupy my scenes don't need to be addressable. They'll just be loaded and uploaded every time I switch scenes. I could maybe look into addressables for objects that are present in many scenes in a row, to improve load times, but only if loading time performance seems bad.
    • Objects that I dynamically instantiate in only a subset of my levels can be addressables, to avoid having to put them into Resources. I'll probably end up with a handful of addressables, one for each major area, each of which have distinct dynamic objects.
    This significantly simplifies things for me. I was previously thinking that every one of my game objects would need to be in an asset bundles / addressable, and that every scene would need to figure out which bundles it needs to load. Thanks again.