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

AdaptiveIcons

class in Unity.Localization.Android

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

Description

Holds one localized Android adaptive launcher icon per screen density.

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.

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
Background The layer drawn behind the foreground, which the launcher may move to animate the icon.
Foreground The layer drawn on top of the background, holding the part of the icon that should stay readable.

Public Methods

Method Description
IsEmpty Reports whether no density has both layers assigned.
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961