Version: Unity 6.7 Alpha (6000.7)
LanguageEnglish
  • C#

AndroidWindowInsets.GetBounds

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 Rect GetBounds(Type type);

Parameters

Parameter Description
type A single inset type to query. Passing combined flags throws an ArgumentException.

Returns

Rect The screen-space rectangle where the overlapping inset covers the application window, or Rect.zero if the inset is not overlapping.

Description

Returns the screen-space rectangle where an overlapping inset covers the application window.

Returns the bounds in Unity screen coordinates (origin bottom-left, y-up), matching the coordinate system of Screen.safeArea. Returns Rect.zero if the specified inset is not overlapping or if AndroidWindowInsets.Type.None is passed. Only a single inset type may be passed; passing combined flags throws an ArgumentException.

The returned rect accounts for resolution scaling when Screen.SetResolution is used.

using UnityEngine;
using UnityEngine.Android;

public class Controller : MonoBehaviour { public void Update() { var statusBarBounds = AndroidApplication.currentWindowInsets.GetBounds(AndroidWindowInsets.Type.StatusBars); if (statusBarBounds.width > 0) Debug.Log("Status bar covers: " + statusBarBounds); } }