Download remote files to use at runtime

Hello great community :slight_smile:

I’m working here on new project
and one of the requirement is to keep client as small as possible…
So we decide to stick to idea that client will download all required additional objects from server.
The problem is that different clients will need different set of objects and it would be preferably to store each object/prefab individually on the server to avoid duplication. Then server can pack it up from the provided by client list of required objects and send it to client.
Ideally I would love to download prepared prefabs (by it unique name) from server, but as far as I understand it is not simple as that to download prefab?

  1. Am I right that if I download “some_file_name.prefab” and save it on client side to the resources folder I wouldn’t be able to run it?
  2. what if prefab was containing some AI scripts attached? would it not work?

I went through manual and come across AssetBundle thing, but it require pro version (what is fine with me) and as far as I understand it also have some complexity to run attached scripts (at least on iOS according to the manual what is very, very bad)
Obviously I can include all AI scripts of all objects/prefabs on the client side as it is not heavy files and after attach required AI script to downloaded prefab but I would prefer to have it all in downloadbl object.

  1. what if once server got download request from client with list of required objects - it would build zip file with all those prefabs and client just download zip?
    and then with c# libraries unzip it to Resources folder? would I be able to instantiate those prefabs?

I definitely know that I can download any file with use of C# and network programming in case if unity native API wouldn’t allow me, but can I use these downloaded prefabs and instantiate them on the client? or to be able to instantiate objects I must use AssetBundle (preferably without scripts attached) full stop?

Well you cannot download code on IOS under any circumstance. It’s a rejection reason and the runtime will just stop you doing it.

AssetBundles can have any scripts attached that are in your released app. It’s normal to maintain asset bundle versions linked to versions of your app to make sure that there is no inconsistency (you pretty much have to do this).

AssetBundles are the way to go I would imagine - though perhaps it would be wise to make up packs of prefabs rather than just using a bundle for each prefab (though that is totally possible).

The only other thing you could do is download models and manually and recreate them, with your own code for what scripts to add and the variable values on them - this would be very painstaking and likely to lead to problems.