| Parameter | Description |
|---|---|
| key | The asset to load. |
| cancellationToken | A token that cancels the load. |
Awaitable<T>
The loaded asset, or null when nothing at the path matches.
Loads the asset for the key from a Resources folder as the requested type.
Resolves the address through any registered alias, then loads it from Resources as T,
or as AssetKey.Type when T is the base Object. When
AssetKey.SubAssetName is set, the named sub-asset at the path is returned. Completes with
null when nothing at the path matches, and throws OperationCanceledException
when the load is cancelled.
<para>Load a sprite from a Resources folder.</para>
using System.Threading; using Unity.Localization.Providers; using UnityEngine;
namespace Unity.Localization.Samples { public class ResourceFolderProviderLoadAssetGenericExample { public async Awaitable Run() { var provider = new ResourceFolderProvider();
var icon = await provider.LoadAssetAsync<Sprite>( new AssetKey("UI/Icons/Settings", typeof(Sprite)), CancellationToken.None);
if (icon != null) Debug.Log(icon.name); } } }