Class Platform
Utility methods and properties related to the Target Platform.
Inherited Members
Namespace: Unity.AppUI.Core
Assembly: Unity.AppUI.dll
Syntax
[InitializeOnLoad]
public static class Platform
Fields
baseDpi
The base DPI value used in PanelSettings.
Declaration
public const float baseDpi = 96
Field Value
| Type | Description |
|---|---|
| float |
Properties
darkMode
Whether the current system is in dark mode.
Declaration
public static bool darkMode { get; }
Property Value
| Type | Description |
|---|---|
| bool |
highContrast
Whether the current system is in high contrast mode.
Declaration
public static bool highContrast { get; }
Property Value
| Type | Description |
|---|---|
| bool |
isHapticFeedbackSupported
Whether the current platform supports haptic feedback.
Declaration
public static bool isHapticFeedbackSupported { get; }
Property Value
| Type | Description |
|---|---|
| bool |
isTouchGestureSupported
Whether the current platform supports touch gestures.
Declaration
public static bool isTouchGestureSupported { get; }
Property Value
| Type | Description |
|---|---|
| bool |
layoutDirection
The current layout direction of the platform.
Declaration
public static int layoutDirection { get; }
Property Value
| Type | Description |
|---|---|
| int |
reduceMotion
Whether the current system uses the "Reduce Motion" accessibility setting.
Declaration
public static bool reduceMotion { get; }
Property Value
| Type | Description |
|---|---|
| bool |
referenceDpi
The DPI value that should be used in UI-Toolkit PanelSettings referenceDpi.
This value is the value of dpi divided by the main screen scale factor.
Declaration
public static float referenceDpi { get; }
Property Value
| Type | Description |
|---|---|
| float |
scaleFactor
The current scale factor applied to the Game view's window.
Declaration
public static float scaleFactor { get; }
Property Value
| Type | Description |
|---|---|
| float |
Remarks
The Game View's window refers to the window that the game is running in (either standalone or in the editor). Multiple game views are not supported.
textScaleFactor
The current system-wide text scale factor.
Declaration
public static float textScaleFactor { get; }
Property Value
| Type | Description |
|---|---|
| float |
Remarks
This is not window specific. The system text scale factor is the scale factor of the text globally applied by the system. For the window specific display scale factor (not text-only), use scaleFactor.
touches
The current touches events for the current platform.
Declaration
public static AppUITouch[] touches { get; }
Property Value
| Type | Description |
|---|---|
| AppUITouch[] |
Remarks
This can be either coming from the Old or New Input System, but also from custom the App UI Input System for trackpad/touchpad support.
Methods
GetSystemColor(SystemColorType)
Get the system color for the given color type.
Declaration
public static Color GetSystemColor(SystemColorType colorType)
Parameters
| Type | Name | Description |
|---|---|---|
| SystemColorType | colorType | The type of system color to get. |
Returns
| Type | Description |
|---|---|
| Color | The system color for the given color type if any, otherwise Color.clear. |
RunHapticFeedback(HapticFeedbackType)
Run a haptic feedback on the current platform.
Declaration
public static void RunHapticFeedback(HapticFeedbackType feedbackType)
Parameters
| Type | Name | Description |
|---|---|---|
| HapticFeedbackType | feedbackType | The type of haptic feedback to trigger. |
Events
darkModeChanged
Event triggered when the system dark mode changes.
Declaration
public static event Action<bool> darkModeChanged
Event Type
| Type | Description |
|---|---|
| Action<bool> |
highContrastChanged
Event triggered when the high contrast mode changes.
Declaration
public static event Action<bool> highContrastChanged
Event Type
| Type | Description |
|---|---|
| Action<bool> |
layoutDirectionChanged
Event triggered when the layout direction of the platform changes.
Declaration
public static event Action<Dir> layoutDirectionChanged
Event Type
| Type | Description |
|---|---|
| Action<Dir> |
reduceMotionChanged
Event triggered when the reduce motion accessibility setting changes.
Declaration
public static event Action<bool> reduceMotionChanged
Event Type
| Type | Description |
|---|---|
| Action<bool> |
scaleFactorChanged
Event that is triggered when the scale factor of the Game view's window changes.
Declaration
public static event Action<float> scaleFactorChanged
Event Type
| Type | Description |
|---|---|
| Action<float> |
Remarks
The Game View's window refers to the window that the game is running in (either standalone or in the editor). Multiple game views are not supported.
textScaleFactorChanged
Event that is triggered when the text scale factor of system changes.
Declaration
public static event Action<float> textScaleFactorChanged
Event Type
| Type | Description |
|---|---|
| Action<float> |
Remarks
This is not window specific. The system text scale factor is the scale factor of the text globally applied by the system. For the window specific scale factor, use scaleFactorChanged.