Search Unity

Basic understanding of loading process

Discussion in 'Addressables' started by any_user, Sep 20, 2018.

  1. any_user

    any_user

    Joined:
    Oct 19, 2008
    Posts:
    374
    I'm trying to understand the loading logic of addressables.

    In a webgl project I'd like to have some assets only download when I actually need them, while always including them in the build. When I do something like the following, will it only download the bundle when it is needed? Or at startup in the download sequence?

    Code (CSharp):
    1. // WebGL: Will it download the bundle right here? Or at startup?
    2. Addressables.LoadAsset<AudioClip>("someaudioclip");
    If I set the LoadPath to "LocalLoadPath" in a webgl build, what does it mean? Does it have any influence on when the bundle is downloaded into RAM or does it really just say where the request should go? I assume even with "LocalLoadPath" selected, it will use http to download it?
     
  2. s-vovik

    s-vovik

    Joined:
    Mar 24, 2017
    Posts:
    15
    Code (CSharp):
    1. // WebGL: Will it download the bundle right here? Or at startup?
    2. Addressables.LoadAsset<AudioClip>("someaudioclip");
    This code will load AudioClip asset "someaudioclip" into RAM and it will be ready for instantiation. The source of loading is depends from LoadPath. As far as I know LocalLoadPath by default is local to application path. For WebGL this means that Group of assets with this path will be downloading from the start, with main application. If you need download assets by request in runtime - you should consider to use RemoteLoadPath (You shold change it. For example http://somehost.com/addressables/[BuildTarget]). Then you should deside do you need to load all group together or you want to load each asset separetly. Set BundleMode to Pack Together ot Pack Separately. You can have as many groups as you like.
     
  3. any_user

    any_user

    Joined:
    Oct 19, 2008
    Posts:
    374
    Thanks, that helps.

    If I use RemoteLoadPath, when will the bundles be downloaded? Do I need to call PreloadDependencies for that? Or if I don't preload, will the download automatically occur when the first of the group's asset is loaded with Addressables.LoadAsset?

    And what are the bundle modes exactly? Does this value influence just how it is loaded, or does it have an impact on how they are bundled?