# AssetKey

> Identifies a single asset to load through an asset provider. The key pairs a provider specific address with an expected asset type, and optionally the name of a sub-asset at that address.

## Definition

* **Type:** Struct
* **Namespace:** [Unity.Localization.Providers](/engine/6000.7/script-reference/unity/localization/providers.md)
* **Assembly:** UnityEngine.LocalizationRuntimeModule
* **Implements:** [IEquatable\<AssetKey>](https://learn.microsoft.com/dotnet/api/system.iequatable-1)

```csharp
public readonly struct AssetKey : IEquatable<AssetKey>
```

## Remarks

The [AssetKey.Address](/engine/6000.7/script-reference/unity/localization/providers/assetkey/address.md) is opaque to the cache and is interpreted by the active provider: [ReferencedAssetProvider](/engine/6000.7/script-reference/unity/localization/providers/referencedassetprovider.md) treats it as the key into its address-to-reference map, [ResourceFolderProvider](/engine/6000.7/script-reference/unity/localization/providers/resourcefolderprovider.md) treats it as a `Resources` path, and a provider installed from a package (for example an Addressables-backed one) can interpret it as its own address. [AssetKey.Type](/engine/6000.7/script-reference/unity/localization/providers/assetkey/type.md) is part of the identity because one address can hold objects of several types, so two keys with the same address but a different type are distinct.

Additional Resources: [IAssetProvider](/engine/6000.7/script-reference/unity/localization/providers/iassetprovider.md), [AssetProvider](/engine/6000.7/script-reference/unity/localization/providers/assetprovider.md), [ReferencedAssetProvider](/engine/6000.7/script-reference/unity/localization/providers/referencedassetprovider.md), [ResourceFolderProvider](/engine/6000.7/script-reference/unity/localization/providers/resourcefolderprovider.md)

Create a key for a texture and inspect its parts.

## Examples

```csharp
using Unity.Localization.Providers;
using UnityEngine;

namespace Unity.Localization.Samples
{
    public class AssetKeyOverviewExample
    {
        public void Run()
        {
            var key = new AssetKey("UI/Flags/Fr", typeof(Texture2D));

            Debug.Log(key.Address);     // UI/Flags/Fr
            Debug.Log(key.Type.Name);   // Texture2D
            Debug.Log(key.IsValid);     // True
        }
    }
}
```

## Constructors

| Constructor                                                                                                                        | Description                                                              |
| ---------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
| [AssetKey(System.String,System.Type,System.String)](/engine/6000.7/script-reference/unity/localization/providers/assetkey/ctor.md) | Creates a key for the given address, interpreted by the active provider. |

## Properties

| Property                                                                                              | Description                                                                             |
| ----------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
| [Address](/engine/6000.7/script-reference/unity/localization/providers/assetkey/address.md)           | The provider-specific address that identifies the asset.                                |
| [IsValid](/engine/6000.7/script-reference/unity/localization/providers/assetkey/isvalid.md)           | Whether this key carries an address.                                                    |
| [SubAssetName](/engine/6000.7/script-reference/unity/localization/providers/assetkey/subassetname.md) | The name of the sub-asset at the address, or null when the key targets the whole asset. |
| [Type](/engine/6000.7/script-reference/unity/localization/providers/assetkey/type.md)                 | The expected asset type.                                                                |

## Methods

| Method                                                                                              | Description                                    |
| --------------------------------------------------------------------------------------------------- | ---------------------------------------------- |
| [Equals](/engine/6000.7/script-reference/unity/localization/providers/assetkey/equals.md)           | Checks whether this key equals another object. |
| [GetHashCode](/engine/6000.7/script-reference/unity/localization/providers/assetkey/gethashcode.md) | Computes a hash code for this key.             |
| [ToString](/engine/6000.7/script-reference/unity/localization/providers/assetkey/tostring.md)       | Returns a readable string describing this key. |

## Operators

| Operator                                                                                              | Description                       |
| ----------------------------------------------------------------------------------------------------- | --------------------------------- |
| [operator ==](/engine/6000.7/script-reference/unity/localization/providers/assetkey/op-equality.md)   | Compares two keys for equality.   |
| [operator !=](/engine/6000.7/script-reference/unity/localization/providers/assetkey/op-inequality.md) | Compares two keys for inequality. |
