Unity 3D: Asset Bundles vs. Folder Resources vs www.Texture

So, I read some forums about AssetBundles and the Resources folder in Unity 3D, and I can’t find the optimal solution to the problem I am facing. Here's the problem:

I have a standalone program that downloads "books" full of .png and .jpg images. The pages are currently the same every time the program starts. At the beginning of the scene for any “book,” she downloads all of these images at once, using www.texture and the path. However, I understand that this is possibly an inefficient method of accessing things at runtime - it is slow! This means that the user can not do anything for 5-20 seconds during the start of the scene and loading the pages of the book (on non-legendary computers). So, I can’t figure out which of the three things will be the fastest:

1) Download one package of assets in a book (say, 20 textures of 1 mb each).

2) Download one resource package per page (1 mb).

3) Either one of the first two parameters, but loaded from the resource folder.

Which one will be faster and why? I understand that asset packs are packaged one by one, but does this mean that textures inside will be pre-compressed and easier in memory at boot time? Does a resource folder cause less loading time? What gives? As far as I understand, the resource folder is loaded into the cache - but is it the same cache that a stand-alone player usually uses? Or is this extra, unused space? I think another problem is that I'm not sure what the difference is between loading things from memory and storing them in the cache.

Greetings, people ...

+6
source share
2 answers

Resource folders combine managed assets. This means that they will be compressed by Unity, following the settings that you apply in the IDE. Therefore, they are effective for loading at runtime. You can adapt compression for each platform, which should further optimize performance.

We make an expensive use of Resources.Load () to pull assets, and it works well on both the desktop and mobile devices.

There is also a special folder called StreamingAssets that you can use to place nested non-managed assets. Here we put the videos that we want to play at runtime, but don’t want Unity to convert them to ogg code by default. On mobile devices, they are played in the native video player. You can also post images there, and uploading them is similar to using the WWW class. Slowly because Unity needs to sanitize and compress images at boot time.

WWW loading is slower due to the overhead of the processing asset, as described above. But you can retrieve data from the server or from outside the sandbox application.

  • Download only what you need to display and implement the background process to get additional content when the user is busy viewing the first pages of each book. This will avoid blocking the user interface for too long.
  • Optimize images to reduce file size. Use tinypng if you need transparent images or stick with compressed JPGs.
  • Try using Power of 2 images where possible. This should speed up the process a bit.

ATH.

+8
source

Great answer from Jerome about Resources. To add additional information for future searches in AssetBundles, consider two scenarios:

Your game is too big

You have a ton of textures, say, and your iOS game is above 100 mb - this means that Apple will show a warning to users and will not allow them to download them via cellular. Resources will not help, because everything in this folder is associated with the application.

Decision. Move artwork that you don’t need the first time you run it in asset packages. Create packages, upload them to the server somewhere, and then upload them at runtime as needed. Now your game is much smaller and will not have any scary warnings.

You need different versions of artwork for different platforms

Alternative scenario: you are developing for iPhone and iPad. For the same reasons as above, you shorten your work as much as possible to reach the limit of 100 mb for iPhone. But now the game looks awful on the iPad. What to do?

Decision. You create an asset package with two options. One for low resolution phones, and one for high resolution tablets. In this case, asset packages can be sent to the game or sent to the server. At runtime, you select the correct option and load from the set of assets, receiving the corresponding illustrations without the need, if / everywhere.

With all that said, asset packages are harder to use, poorly documented, and Unity demos don't work properly at times. Therefore, seriously evaluate whether you need them.

+4
source

Source: https://habr.com/ru/post/948529/


All Articles