Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


AndroidWindowInsets

Provides control over the windows that generate insets.
Read time 2 minutesLast updated 5 days ago

Definition

public class AndroidWindowInsets

Remarks

These windows represent the system UI elements for system bars, such as the status and navigation bars. Use this class to determine the current state of the system bars, control their visibility and behavior at runtime, allowing your application to make full use of the device screen space.
Additional Resources: About window insets (Android)

Examples

using UnityEngine;using UnityEngine.Android;public class AndroidInsets : MonoBehaviour{ public string GetInsetsVisibility(AndroidWindowInsets.Type type) { if (AndroidApplication.currentWindowInsets == null) return "Unknown"; return AndroidApplication.currentWindowInsets.IsVisible(type) ? "Visible" : "Hidden"; } public void OnGUI() { var options = new[] { GUILayout.Height(100), GUILayout.ExpandWidth(true) }; GUILayout.Space(100); GUILayout.Label($"Status Bars: {GetInsetsVisibility(AndroidWindowInsets.Type.StatusBars)}", options); GUILayout.Label($"Navigation Bars: {GetInsetsVisibility(AndroidWindowInsets.Type.NavigationBars)}", options); var insets = AndroidApplication.currentWindowInsets; GUILayout.BeginHorizontal(GUILayout.Width(Screen.width)); if (GUILayout.Button("Show Status Bars", options)) insets.Show(AndroidWindowInsets.Type.StatusBars); if (GUILayout.Button("Hide Status Bars", options)) insets.Hide(AndroidWindowInsets.Type.StatusBars); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(GUILayout.Width(Screen.width)); if (GUILayout.Button("Show Navigation Bars", options)) insets.Show(AndroidWindowInsets.Type.NavigationBars); if (GUILayout.Button("Hide Navigation Bars", options)) insets.Hide(AndroidWindowInsets.Type.NavigationBars); GUILayout.EndHorizontal(); GUILayout.Label($"System Bars Behavior: {insets.GetSystemBarsBehavior()}", options); GUILayout.BeginHorizontal(GUILayout.Width(Screen.width)); if (GUILayout.Button("Default", options)) insets.SetSystemBarsBehavior(AndroidWindowInsets.SystemBarsBehavior.Default); if (GUILayout.Button("ShowTransientBarsBySwipe", options)) insets.SetSystemBarsBehavior(AndroidWindowInsets.SystemBarsBehavior.ShowTransientBarsBySwipe); GUILayout.EndHorizontal(); }}

Methods

Method

Description

GetSystemBarsBehaviorRetrieves the configured behavior of system bars, such as status and navigation bars.
HideHides a set of windows that generate insets.
IsVisibleIndicates whether a set of windows that might generate insets is currently visible on screen, regardless of whether they overlap with your application window.
SetSystemBarsBehaviorControls the behavior of system bars.
ShowDisplays a set of windows that generate insets on screen.

Enums

Enum

Description

AndroidWindowInsets.SystemBarsBehaviorOptions for controlling the behavior of system bars, such as the status and navigation bars.
AndroidWindowInsets.TypeOptions for specifying different types of system UI elements that generate window insets.