Skip to content

On-Demand Resource Loading ​

Unlike native APP games, which usually download all resources during installation and startup, minigames need to achieve "instant play." At startup only a small amount of resources can be loaded, and the rest must be placed on a CDN for lazy loading. How to load resources on demand reasonably and efficiently is very important.

Currently there are three sub-packaging schemes: on-demand loading based on AA/AB packages, and Unity Instant Game. It is worth noting that the minigame environment does not support loading local Bundles, so regardless of the scheme, the final approach is to upload to a CDN and download asynchronously on demand while the game is running.

Notes on Choosing AA Packages, AB Packages, and Instant Game ​

AA/AB packages are the conventional sub-packaging solution. As for the choice between them, for light games there is no particular requirement; the powerful AA package actually has a lower barrier to use. For hardcore games, the conclusion the platform has received so far is that the performance of AB packages is better than AA packages. AA packages generate a large uncompressed catalog for larger projects, resulting in low loading efficiency; switching to AB packages produces a noticeable improvement.

Instant Game is an automatic loading solution provided officially by Unity. For details on Instant Game, refer to the Instant Game practice guide. This section explains the differences between the three schemes:

Selection Recommendations ​

If the game project itself already uses well-established AA/AB resource management, it is recommended to continue using the conventional resource loading scheme, which also helps with subsequent optimization work such as texture compression to effectively improve game runtime performance.

If the native APP version of the game does not do any resource splitting at all, and you want to reduce the game's conversion cycle, using the Instant Game scheme can quickly complete the conversion work.

Resource Optimization Recommendations for Various Game Types ​

Different games require different performance, so the complexity during conversion and the focus of attention naturally differ. Game developers can adopt different optimization strategies based on their own game type to improve the actual game experience. This section summarizes and lists the optimization content that developers should focus on for different types of games.

Native APP Mobile Games That Already Use AB/AA Packages and Other On-Demand Resource Loading** ​

Characteristics: The game was originally published on native APP platforms, storing game resources locally on disk as AA/AB packages, and loading/unloading them at appropriate points while the game runs.

Optimization recommendations:

  • Load AA/AB resource packages remotely via CDN, promptly unload resource packages no longer in use to free memory, and combine with texture compression optimization to reduce package size.
  • When the APP uses AB asynchronously (such as AssetBundle.LoadAssetAsync), change it to download and create the AB from UnityWebRequest. For details, refer to Use AssetBundle for on-demand resource loading.
  • When the APP uses AB synchronously (such as AssetBundle.LoadFromFile, AssetBundle.LoadAssetAsync), change it to create the AB via the UnityWebRequest asynchronous interface, and use asynchronous interfaces such as LoadAssetAsync. Modifying to asynchronous interfaces may involve business logic changes; when the workload is very large, you can also combine Unity Instant Game for on-demand resource loading to automatically strip out some resources.
  • AssetBundle no longer needs to use the local file system cache or version updates; the minigame adaptation plugin already caches automatically. Please refer to Resource caching.
  • Large games are not advised to use Addressable, because when the number of keys reaches several thousand, the resource index file (catalog) built often becomes very large, putting significant pressure on downloading and parsing.

Native APP Mobile Games (Light Games) That Do Not Use On-Demand Resource Loading ​

Characteristics: The total package size of the game is small, such as "level-based" casual minigames.

Optimization recommendations:

  • Quickly adapt the integration of API capabilities; for performance, focus on first-scene startup optimization and level sub-package loading (main level first, subsequent levels loaded on demand, etc.).

  • It is recommended to use Unity Instant Game for on-demand resource loading to shorten the conversion cycle.

Native APP Mobile Games (Mid-core and Hardcore Games) That Do Not Use On-Demand Resource Loading ​

Characteristics: The game is relatively large but does not use AA/AB packages for sub-package management, or uses them rarely, and non-time-sensitive resources in the scene must be loaded together at startup.

Optimization recommendations:

  • This type of game requires patient tuning. In-game resources need to be split one by one; it is recommended to use AB packages for on-demand loading and prompt resource release. For multiple Scenes, load subsequent scenes using AA/AB sub-packaging.

  • Provide good progress bar feedback in the UI during resource loading.