Search Unity

How to create a "pre-cached" build for remote contents?

Discussion in 'Addressables' started by horeaper, Jul 21, 2019.

  1. horeaper

    horeaper

    Joined:
    Oct 30, 2013
    Posts:
    47
    My game uses a "all remote" asset approach, which means I set all assets to "build to Remote, load from Remote, and Pack Separately" strategy. I even changed the default group's build/load path to remote so I don't need to "move" every asset to another group when I make it addressable.

    Now I want to distribute a "pre-cached" install, which contains all assets locallly, so the user does not need to download them again. But if an asset is updated on the remote server (which happens every 1 or 2 weeks), the program can still get the latest copy online.

    How can I do that?
     
  2. horeaper

    horeaper

    Joined:
    Oct 30, 2013
    Posts:
    47
    Some background info:

    Currently my distributed install file is about 50MB, contains only a few "startup" assets. When the player launches the game on the first time, it will download the "minimal required" assets, which is needed to run the game (about 500MB). The entire game assets is around 17GB, all remaining ones will get downloaded in-game, when it's required.

    The thing is, many user complains about the slow in-game download speed (especially new users). They wish to download a "complete install" using their download manager software, and start playing right away.
    Changing my default asset group to "Local + Static" might solve the problem, but for one, not all users complains, some are actually very happy about the current strategy, when they switch to a new device (for some reason, many of our user switchs device very often), they don't need to wait too long to start the game. Another reason is I want to keep my install file small, so download/update the program itself (which happens basically every month) can still be very fast, I don't know how to do that using "Local" build/load strategy.

    In summary, what I want are two kind of download on my website:
    The 50MB one that can "get started" very quickly.
    The 17GB one which can be downloaded through bittorrent or something, and provide a smooth in-game experience.

    (fast CDNs are expensive....:()
     
  3. M_R

    M_R

    Joined:
    Apr 15, 2015
    Posts:
    559
    you could use a profile where "remote" actually points to streaming assets or a local folder, then zip that with the exe...
     
  4. horeaper

    horeaper

    Joined:
    Oct 30, 2013
    Posts:
    47
    But that will lose the ability to auto update...
     
  5. Favo-Yang

    Favo-Yang

    Joined:
    Apr 4, 2011
    Posts:
    464
  6. horeaper

    horeaper

    Joined:
    Oct 30, 2013
    Posts:
    47
    Actually it's not similar. The goal of mine is to provide two kind of downloads, using the same update path, for end users.
    My guess is I need to modify something on the build process.
     
  7. Favo-Yang

    Favo-Yang

    Joined:
    Apr 4, 2011
    Posts:
    464
    If you don't mind to lose the ability to update in the fat build version. Then it's a lot easier.
    - For the thin build, change the "Load Path", "Build Path" of group settings to remote version.
    - For the fat build, change the "Load Path", "Build Path" of group settings to local version.

    However if you want the fat build to be updatable... we still need search for an elegant way. Designing a fallback system has many drawbacks like complex load logic and duplicated space.

    My best guess is that in the fat build, move the pre-cache asset bundle into the AAS cache folder and modify the local catalog to cheat AAS that the bundles has been fetched. After AAS getting the remote catalog, it will find nothing change, and serves asset from local. I use this approach in an old game (built with other game engine), and it works well.
     
    unity_bill likes this.
  8. horeaper

    horeaper

    Joined:
    Oct 30, 2013
    Posts:
    47
    I was thinking something like a checkbox on AddressableAssetSettings with "Pre-Cache Remote Data", and only affects remote bundles.
     
  9. horeaper

    horeaper

    Joined:
    Oct 30, 2013
    Posts:
    47
    Seems there's no easy solution to this...
     
  10. Favo-Yang

    Favo-Yang

    Joined:
    Apr 4, 2011
    Posts:
    464
    Well not as easy as toggling a checkbox on group, but workable.

    Try these steps
    - Build remote group as usual, make sure group name with hash appended.
    - Custom build script to copy pre-cache bundle from the RemoteBuildPath to your LocalBuildPath.
    - Build app (so pre-cache bundle ship with app build).
    - Write a custom bundle provider, and implement the fallback logic.
     
    unity_bill likes this.