# 4. Labels and Loading Many Assets Part of [[Addressables]]. Previous: [[3. Loading Instantiating and Releasing]]. Next: [[5. Scenes Catalogs and Remote Content]]. > [!note] Verification status > `LoadAssetsAsync`, `Addressables.MergeMode` (`Union`, `Intersection`, `UseFirst`), the `releaseDependenciesOnFailure` flag, and subasset address syntax are from the Addressables 2.9.1 "Load assets" manual. **Code not compiled in Unity.** ## 4.1 Labels as sets A label is a cheap way to say "everything I need for the harbor" or "all enemy portraits." You can apply several labels to one entry (`location-harbor` + `character`). ```csharp using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.ResourceManagement.AsyncOperations; public sealed class LoadHarborProps : MonoBehaviour { public List<string> keys = new() { "location-harbor", "props" }; AsyncOperationHandle<IList<GameObject>> _handle; IEnumerator Start() { _handle = Addressables.LoadAssetsAsync<GameObject>( keys, prefab => { if (prefab != null) Instantiate(prefab, transform); }, Addressables.MergeMode.Intersection, false); yield return _handle; if (_handle.Status != AsyncOperationStatus.Succeeded) Debug.LogWarning("Some harbor props failed to load."); } void OnDestroy() { if (_handle.IsValid()) _handle.Release(); } } ``` Merge modes, when you pass **multiple keys**: | Mode | Result | |---|---| | `Union` | Assets that match *any* key | | `Intersection` | Assets that match *every* key | | `UseFirst` | Only the first key that resolves to a valid location | The callback runs per loaded asset. The last boolean is `releaseDependenciesOnFailure`: - `true` — any single failure fails the operation and **releases what already loaded**. Use this when the set is useless incomplete (a level's required props). - `false` — load what you can; the handle can complete as `Failed` with nulls in the list for the missing entries. Use this when extras are optional. Releasing `_handle` releases the loaded assets. If you parented instances under this object, destroying the object plus releasing the handle is a clean pair. If instances live elsewhere, you must keep the handle alive until those instances are done — or load the prefab once, hold one handle, and `Instantiate` copies yourself. ## 4.2 Subassets (sprites, clips) You cannot load a `Component` off a GameObject directly through Addressables (load the GameObject, then `GetComponent`). For **subassets** the 2.9.1 manual specifies: - All subassets: load `IList<T>` at the parent address, e.g. a sprite sheet - One named subasset: `Addressables.LoadAssetAsync<Sprite>("MySpriteSheetAddress[MySpriteName]")` The square-bracket suffix is official. Confirm the exact address string in the Groups window; a typo looks like a missing catalog entry. ## 4.3 Teaching use: a chapter kit Label every asset for chapter 2 with `chapter-2`. On chapter start, `LoadAssetsAsync` with that label and a progress bar. On chapter end, release the handle. That is a streaming story you can play in a 50-minute lab, without a remote server. ## Official docs - Load assets (2.9.1): https://docs.unity3d.com/Packages/[email protected]/manual/load-assets.html