TryLoadAsset<T>(AssetKey, out T)
Resolves the referenced asset for the key without an asynchronous load.
Read time 1 minuteLast updated 14 days ago
Definition
- Type: Method
- Namespace: Unity.Localization.Providers
- Assembly: UnityEngine.LocalizationRuntimeModule
TryLoadAsset<T>(AssetKey, T)
public bool TryLoadAsset<T>(AssetKey key, out T asset) where T : Object
Parameters
Returns
Type | Description |
|---|---|
| bool | |
Remarks
Returns and the asset when the address is registered and the asset is a (or matches AssetKey.Type when is the base Object); otherwise returns with a asset. Because the assets are already in memory, this provider only implements the synchronous capability.
trueTTfalsenullRegister a texture by address and resolve it back through the provider.
Examples
using Unity.Localization.Providers;using UnityEngine;namespace Unity.Localization.Samples{ public class ReferencedAssetProviderLoadAssetGenericExample { public void Run() { var provider = new ReferencedAssetProvider(); provider.Add("UI/Logo", new Texture2D(2, 2)); if (provider.TryLoadAsset<Texture2D>(new AssetKey("UI/Logo", typeof(Texture2D)), out var logo)) Debug.Log(logo.name); } }}