c# – How to load game files from the server at startup on android?


Please give me directions on how to download files from the server when starting the game, so that in the future you can add / change the background, music, etc.


The main part of the assets is included in the project itself at the compilation stage, which means that simply downloading the file and using it will not work. All files are literally built into the project itself at the compilation stage.

But sometimes you need to access files through pathname. For example: video playback on iOS is possible only by path. Or, say, downloading new resources from the Internet and loading them at runtime. This is possible with Streaming Assets .

How to use it – in the manual on the link. Dig this way.

To be blunt and short:

  1. Create a folder in the StreamingAssets project
  2. You learn to access the files that are in this folder (the access is carried out along a specific path, and not as usual in unity)
  3. Using the http request, you save the file there, for example, a zip folder with the necessary resources in the correct structure, unzip it into the same folder and access the resources at runtime.

You also need to keep in mind that standard resources are converted to "standard formats" for the unit and optimized. You also need to keep in mind that if you do not prepare the resource, it will work more slowly. the unit will convert resources on the fly. For example compress textures.

Also, please upvote KingPeas' answer . He completed the answer in a very nice way — Asset Bundle . I think even better than I first remembered 🙂

They were created precisely in order to prepare and simplify the download (because all the resources you need can be thrown into 1 file and, for example, the textures are immediately compressed by the unit, and this is not done on the fly, as is the case with Streaming Assets.)

Scroll to Top