Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


AdaptiveIcons

Holds one localized Android adaptive launcher icon per screen density.
Read time 1 minuteLast updated 7 days ago

Definition

public class AdaptiveIcons

Remarks

An adaptive icon is a background and a foreground layer the operating system composes and masks to whatever shape the launcher uses, so a density needs both layers to be usable. Assign both layers at every density: Unity writes a locale only when the whole set resolves, because mixing a layer from one density with a layer scaled from another distorts the icon, and a partial set would still outrank the Player Settings icons for that locale. Android 8.0 introduced adaptive icons, so populate AppInfo.LegacyIcons as well to cover older devices.
Additional Resources: AppInfo, Icons, IconDensity
Assign a localized adaptive icon for one density.

Examples

using Unity.Localization;using Android = Unity.Localization.Android;namespace Unity.Localization.Samples{ public class AndroidAdaptiveIconsExample { // Both layers at every density, or the locale keeps the icons from the Player Settings. static readonly (Android.IconDensity density, string suffix)[] k_Densities = { (Android.IconDensity.Low, "ldpi"), (Android.IconDensity.Medium, "mdpi"), (Android.IconDensity.High, "hdpi"), (Android.IconDensity.ExtraHigh, "xhdpi"), (Android.IconDensity.ExtraExtraHigh, "xxhdpi"), (Android.IconDensity.ExtraExtraExtraHigh, "xxxhdpi") }; public void Run(Android.AppInfo appInfo) { var icons = appInfo.AdaptiveIcons; foreach (var (density, suffix) in k_Densities) { icons.Background.GetIcon(density).SetReference("App Icons", $"Icon Background {suffix}"); icons.Foreground.GetIcon(density).SetReference("App Icons", $"Icon Foreground {suffix}"); } } }}

Properties

Property

Description

BackgroundThe layer drawn behind the foreground, which the launcher may move to animate the icon.
ForegroundThe layer drawn on top of the background, holding the part of the icon that should stay readable.

Methods

Method

Description

IsEmptyReports whether no density has both layers assigned.