ResourceFolderProvider
An asset provider that loads assets from Resources folders, treating the address as a Resources path.
Read time 1 minuteLast updated 10 days ago
Definition
- Type: Class
- Namespace: Unity.Localization.Providers
- Assembly: UnityEngine.LocalizationRuntimeModule
- Implements: IAsyncAssetProvider, IAssetProvider, ISynchronousAssetProvider
public sealed class ResourceFolderProvider : IAsyncAssetProvider, IAssetProvider, ISynchronousAssetProvider
Remarks
An address that does not resolve to an asset in a folder is a miss and returns , so addresses meant for other providers do not resolve here. Because this provider always loads by path, a table referenced by collection guid cannot address it directly. Register a guid-address to path alias with ResourceFolderProvider.AddAlias so a guid reference still resolves.
ResourcesnullResourcesLoad an asset from a Resources folder by path.
Examples
using System.Threading;using Unity.Localization.Providers;using UnityEngine;namespace Unity.Localization.Samples{ public class ResourceFolderProviderOverviewExample { public async Awaitable Run() { var provider = new ResourceFolderProvider(); var logo = await provider.LoadAssetAsync<Texture2D>( new AssetKey("UI/Logo", typeof(Texture2D)), CancellationToken.None); if (logo != null) Debug.Log(logo.name); } }}
Methods
Method | Description |
|---|---|
| AddAlias | Maps an address to a Resources path, replacing any existing alias for that address. |
| LoadAssetAsync | Loads the asset for the key from a Resources folder as the requested type. |
| Release | Unloads an asset previously loaded from a Resources folder. |
| Remove | Removes any alias registered under the given address. |