Version: Unity 7.0 Alpha (7000.0)
LanguageEnglish
  • C#

Icons.GetIcon

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 LocalizedTexture GetIcon(IconDensity density);

Parameters

Parameter Description
density The density to read.

Returns

LocalizedTexture The icon for that density.

Description

Returns the icon assigned for a density.

The returned object is the stored one, so assigning to its properties changes what this type holds. Every density has an icon object from the moment this type is created; an unassigned one reports LocalizedReference.IsEmpty as true.

Additional resources: IconDensity

Assign a localized icon for one density.

using Unity.Localization;
using Android = Unity.Localization.Android;

namespace Unity.Localization.Samples { public class AndroidIconsExample { // Every density has to be assigned, or the locale keeps the icons from the Player Settings. static readonly (Android.IconDensity density, string key)[] k_Icons = { (Android.IconDensity.Low, "Launcher Icon ldpi"), (Android.IconDensity.Medium, "Launcher Icon mdpi"), (Android.IconDensity.High, "Launcher Icon hdpi"), (Android.IconDensity.ExtraHigh, "Launcher Icon xhdpi"), (Android.IconDensity.ExtraExtraHigh, "Launcher Icon xxhdpi"), (Android.IconDensity.ExtraExtraExtraHigh, "Launcher Icon xxxhdpi") };

public void Run(Android.AppInfo appInfo) { foreach (var (density, key) in k_Icons) appInfo.LegacyIcons.GetIcon(density).SetReference("App Icons", key); } } }