When creating asset bundles,
you have the option to compress the files.
Now, there's a pro and con to compressing,
and there's a couple different ways that you can compress.
So, let's have a look at that.
Now, if I go over to the Build tab,
under Advanced settings, I have a option for compression.
The options are; no compression,
standard compression or LZMA,
and chunk based compression or LZ4.
Understanding the pros and cons to compressing,
and the different compressing methods is going to be integral if you want to optimize
your game to be downloaded and played across a variety of devices.
The uncompressed asset bundle setting is obviously the largest but it's also the fastest.
The processor doesn't have to do anything to make the files accessible to your game.
The next largest is the LZ4 setting.
Now, this is larger than the LZMA but it does have a large advantage to it.
LZ4 can have aspects of it or
individual files taken out without processing the entire file.
This means taken out a single asset can be faster and also uses up a lot less memory.
Now, the smallest compression method is LZMA but that also means it's the slowest.
The entire asset needs to be loaded in the memory
and decompress before any asset within it can be accessed.
Now, either of the compressions can also have small complications.
Particularly in Android, if a asset bundles included in the Apk,
it's obviously stored in the Apk.
This must be decompress before it can be even accessed.
Compressing asset bundles does take longer to build but you get
a smaller install if you include those files with the initial distribution of the game.
You get a bigger install and a faster build if you are not compressing.
Now, if memory is a concern,
the uncompressed and the LZ4 for compression method takes up less memory.
Uncompressed and LZ4 take up very little memory to access,
LZ4 in particular doesn't have very much memory overhead because you're able to access
the individual portions of the asset bundle without having to uncompress all of it.
Now, of course, compression is better for downloading smaller file sizes
mean less time the player's spent downloading and more time playing the game.
Something to be aware of,
if you're creating a WebGL project,
do watch how about compressing your asset bundles.
WebGL does any decompression on the main thread,
which means you're gonna be taking performance away from
a game-play if you're trying to load something asynchronously.
Finally, if you're developing your game for WebGL,
do watch out and don't compress your asset bundle files.
WebGL can only decompress using the main thread,
it can't use worker threads.
This means that you might suffer a performance impact if you're loading your files
asynchronously and trying to let the player play the game at the same time.