WuhuIslandTesting/Library/PackageCache/com.unity.addressables@1.21.12/Documentation~/runtime/LoadingMultipleAssets.md
2025-01-07 02:06:59 +01:00

7.7 KiB

uid
addressables-loading-multiple-assets

Loading multiple assets

Use the LoadAssetsAsync method to load more than one Addressable asset in a single operation. When using this function, you can specify a single key, such as a label, or a list of keys.

When you specify multiple keys, you can specify a merge mode to determine how the sets of assets matching each key are combined:

  • __Union __: include assets that match any key
  • __Intersection __: include assets that match every key
  • UseFirst: include assets only from the first key that resolves to a valid location

[!code-cssample]

You can specify how to handle loading errors with the releaseDependenciesOnFailure parameter. If true, then the operation fails if it encounters an error loading any single asset. The operation and any assets that did successfully load are released.

If false, then the operation loads any objects that it can and does not release the operation. In the case of failures, the operation still completes with a status of Failed. In addition, the list of assets returned has null values where the failed assets would otherwise appear.

Set releaseDependenciesOnFailure to true when loading a group of assets that must be loaded as a set in order to be used. For example, if you are loading the assets for a game level, it might make sense to fail the operation as a whole rather than load only some of the required assets.