Class SafeArea
A component that drives a RectTransform to fit within the device's safe area.
Inherited Members
Namespace: UnityEngine.UI
Assembly: UnityEngine.UI.dll
Syntax
[DisallowMultipleComponent]
[RequireComponent(typeof(RectTransform))]
[AddComponentMenu("UI (Canvas)/Safe Area")]
[ExecuteAlways]
public class SafeArea : MonoBehaviour
Remarks
Inset edges, alignment centering, and reference orientation are configurable. Edge and alignment directions are authored in the reference orientation and remapped to the current device orientation at runtime.
Properties
Alignment
Controls which axis to center the rect by equalizing insets on both sides
Declaration
public SafeArea.AlignmentMode Alignment { get; set; }
Property Value
| Type | Description |
|---|---|
| SafeArea.AlignmentMode |
Edges
Controls which edges of the device to inset to respect the safe area
Declaration
public SafeArea.SafeAreaMode Edges { get; set; }
Property Value
| Type | Description |
|---|---|
| SafeArea.SafeAreaMode |
ReferenceOrientation
The reference orientation to determine edges to respect safe area
Declaration
public ScreenOrientation ReferenceOrientation { get; set; }
Property Value
| Type | Description |
|---|---|
| ScreenOrientation |
RespectSafeAreaScreenBottom
Whether this UI component respects (inset to) the safe area on the screen's bottom edge for the current device orientation.
Declaration
public bool RespectSafeAreaScreenBottom { get; }
Property Value
| Type | Description |
|---|---|
| bool |
RespectSafeAreaScreenLeft
Whether this UI component respects (inset to) the safe area on the screen's left edge for the current device orientation.
Declaration
public bool RespectSafeAreaScreenLeft { get; }
Property Value
| Type | Description |
|---|---|
| bool |
RespectSafeAreaScreenRight
Whether this UI component respects (inset to) the safe area on the screen's right edge for the current device orientation.
Declaration
public bool RespectSafeAreaScreenRight { get; }
Property Value
| Type | Description |
|---|---|
| bool |
RespectSafeAreaScreenTop
Whether this UI component respects (inset to) the safe area on the screen's top edge for the current device orientation.
Declaration
public bool RespectSafeAreaScreenTop { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Methods
GetReferenceOrientationMappedDirection(SafeAreaMode)
Calculate and return the orientation that any given reference orientation direction is mapped to.
Declaration
public SafeArea.SafeAreaMode GetReferenceOrientationMappedDirection(SafeArea.SafeAreaMode referenceOrientationDirection)
Parameters
| Type | Name | Description |
|---|---|---|
| SafeArea.SafeAreaMode | referenceOrientationDirection | The direction in reference orientation space to map. |
Returns
| Type | Description |
|---|---|
| SafeArea.SafeAreaMode | The direction in screen space for the current device orientation. |