Version: Unity 6.7 Alpha (6000.7)
LanguageEnglish
  • C#

AssetKey.Equals

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public bool Equals(AssetKey other);

Parameters

Parameter Description
other The key to compare with this one.

Returns

bool true if both keys identify the same asset; otherwise, false.

Description

Checks whether this key identifies the same asset as another.

Two keys are equal when their addresses match by ordinal comparison, their sub-asset names match by ordinal comparison, and their AssetKey.Type values are the same. Keys with the same address but a different type are not equal.

<para>Compare two keys built for the same asset.</para>

using Unity.Localization.Providers;
using UnityEngine;

namespace Unity.Localization.Samples { public class AssetKeyEqualsExample { public void Run() { var a = new AssetKey("UI/Logo", typeof(Texture2D)); var b = new AssetKey("UI/Logo", typeof(Texture2D));

Debug.Log(a.Equals(b)); // True } } }

Declaration

public bool Equals(Object obj);

Parameters

Parameter Description
obj The object to compare with this key.

Returns

bool true if obj is a key that identifies the same asset; otherwise, false.

Description

Checks whether this key equals another object.

Returns false when obj is not an AssetKey. Otherwise, defers to AssetKey.Equals for value comparison.

<para>Compare against a boxed key.</para>

using Unity.Localization.Providers;
using UnityEngine;

namespace Unity.Localization.Samples { public class AssetKeyEqualsObjectExample { public void Run() { var key = new AssetKey("UI/Logo", typeof(Texture2D)); object boxed = new AssetKey("UI/Logo", typeof(Texture2D));

Debug.Log(key.Equals(boxed)); // True } } }