AssetBundle.LoadFromStream vs LoadFromFile, differences?

Hi, what are the differences between these two? In both cases I can read assetbundles which are stored in the disk and consequently load them. So what is the differences in between? When should I use what? :eyes::eyes:

I think you messed up in your title there, buddy.

Thanks a lot, subconsciously it was ok ever since :p:p.

LoadFromFile loads from a file, while LoadFromStream loads from a stream!

A file needs to be a file on your harddrive. A stream is a generalized concept for a bunch of bytes arriving in order. It could be pretty much anything.

The example for LoadFromStream uses a filestream, which is a bit redundant, as they could’ve just used LoadFromFile. A stream is more convenient if you’re receiving a file over the network. LoadFromFile would require you to download the file, store it somewhere, and then read from it. LoadFromStream would allow you to stream the file data directly, and never have there be a file on the downloading computer’s file system.

Look at the inheritance hierarchy here to see what kinds of built-in C# things are streams. LoadFromStream can load from all of those.

ok then it is probably not for me. I won’t be loading anything over network directly. Anything which users need should get themselves downloaded into well defined locations into user’s device first, like an API call:

AsyncOperation op = DLC_API.DownloadToDiskAsync("bundleName", "url", "diskPathRelativeToPersistant_or_whateverLikeThat");

Then when I need to load them I can just use LoadFromFile()! In my use case, I don’t see any need for ‘LoadFromStream’. Right?

The philosophy here is: “Users wont have internet connection all the time(may be most of time offline!!) but user can always play games no matter when.”