Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


AssetKey(string, Type, string)

Creates a key for the given address, interpreted by the active provider.
Read time 1 minuteLast updated 16 days ago

Definition

public AssetKey(string address, Type type = null, string subAssetName = null)

Parameters

address

The provider-specific address, for example a
Resources
path.

type

The expected asset type. Defaults to Object.

subAssetName

The optional name of a sub-asset at the address.

Remarks

An empty or null
address
produces a key whose AssetKey.IsValid is
false
, which providers treat as a miss. When
type
is
null
, AssetKey.Type reports Object. Pass
subAssetName
to target a named sub-asset at the address, such as one sprite in a sheet.
Create a key for a whole asset and a key for a named sub-asset.

Examples

using Unity.Localization.Providers;using UnityEngine;namespace Unity.Localization.Samples{ public class AssetKeyConstructorExample { public void Run() { var icon = new AssetKey("UI/Icons/Settings", typeof(Sprite)); var sheetEntry = new AssetKey("UI/Atlas", typeof(Sprite), "Settings"); Debug.Log(icon.SubAssetName == null); // True Debug.Log(sheetEntry.SubAssetName); // Settings } }}