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

AssetKey Constructor

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 AssetKey(string address, Type type, string subAssetName);

Parameters

Parameter Description
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.

Description

Creates a key for the given address, interpreted by the active provider.

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.

<para>Create a key for a whole asset and a key for a named sub-asset.</para>

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