ドキュメント

Unity Engine

Unity Engine

Equals

Checks whether this key identifies the same asset as another.
読み終わるまでの所要時間 1 分最終更新 1ヶ月前

Definition

Equals(AssetKey)

Checks whether this key identifies the same asset as another.
public bool Equals(AssetKey other)

Parameters

The key to compare with this one.

Returns

Type

Description

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

Remarks

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.
Compare two keys built for the same asset.

Examples

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 } }}

Equals(Object)

Checks whether this key equals another object.
public override bool Equals(object obj)

Parameters

The object to compare with this key.

Returns

Type

Description

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

Remarks

Returns
false
when
obj
is not an AssetKey. Otherwise, defers to AssetKey.Equals for value comparison.
Compare against a boxed key.

Examples

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 } }}