0
\$\begingroup\$

I am deciding on how to package my asset bundles that will be loaded from the web server at some point in the game. Currently I am thinking of packing them by types: for example, I would have one asset bundle that contains all the backgrounds, another for some UI elements and so on.

In-game I would load only specific background at a specific time by its name (I will know the name in advance so I don't have to get it from the bundle).

If I do it this way, will only that background get downloaded, or the whole bundle?

The target platform will be WebGL, so limiting memory and download time is important.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ This seems like the plain meaning of the word "bundle" - a group of things that are gathered together for transport. If it was just a spread you could pick one item from at a time, that would be an "Asset Library" or "AssetBuffet" 😜 \$\endgroup\$
    – DMGregory
    Commented May 9, 2023 at 12:01

1 Answer 1

2
\$\begingroup\$

Yes, the whole asset bundle will be downloaded. A webserver can't look into the asset bundles and deliver just a part of it. It's all or nothing.

So if you want to optimize the loading times and memory footprint by streaming only the assets you need, then you need to organize your asset bundles so that the files you usually request together are in the same bundle. And dependencies between bundles should be avoided, unless you are going to need almost everything from both bundles anyway.

Addressables can help you as an abstraction layer between your game code and your asset bundles. When you refer to assets by Addressable addresses instead of a combination of a specific asset bundle and filename, then you can easily experiment with moving assets between bundles without having to edit your code.

\$\endgroup\$
3
  • \$\begingroup\$ I didn't use Addressable I will look into it, but if I understand you correctly there is no way to download only a part of the bundle ight? \$\endgroup\$
    – Ivan
    Commented May 9, 2023 at 10:42
  • \$\begingroup\$ No, there is not. From the perspective of your webserver, each asset bundle file is just a big blob of binary data. \$\endgroup\$
    – Philipp
    Commented May 9, 2023 at 10:43
  • 2
    \$\begingroup\$ It might be worth pointing out that this bundling is a good thing for typical game workloads. You rarely want just one file - like the "jungle" background. You probably want the jungle theme music and the library of jungle props at the same time. And you want to pay the overhead of fetching assets from a server, allocating memory for them, parsing and decompressing the downloaded payload as few times as possible, rather than for every file individually. If you bundle well, your game will run better than a game that fetches files one at a time. \$\endgroup\$
    – DMGregory
    Commented May 9, 2023 at 12:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .