GetHashCode()
Computes a hash code for this key.
Read time 1 minuteLast updated 13 days ago
Definition
- Type: Method
- Namespace: Unity.Localization.Providers
- Assembly: UnityEngine.LocalizationRuntimeModule
public override int GetHashCode()
Returns
Type | Description |
|---|---|
| int | An integer hash code derived from the address, sub-asset name, and type. |
Remarks
Consistent with AssetKey.Equals: keys that compare equal produce the same hash code. Derived from the address, sub-asset name, and type, so a key is safe to use as a dictionary key for a load cache.
Use a key as a dictionary key for loaded assets.
Examples
using System.Collections.Generic;using Unity.Localization.Providers;using UnityEngine;namespace Unity.Localization.Samples{ public class AssetKeyHashCodeExample { public void Run() { var loaded = new Dictionary<AssetKey, Texture2D>(); var key = new AssetKey("UI/Logo", typeof(Texture2D)); loaded[key] = new Texture2D(2, 2); Debug.Log(loaded.ContainsKey(new AssetKey("UI/Logo", typeof(Texture2D)))); // True } }}