uGUI layout group that makes children respect the Safe Area. It drives children's anchors and supports LayoutElement.ignoreLayout
Unity GUI layout group
that makes children respect the Safe Area.
It drives direct children's anchors while in Play Mode and supports LayoutElement.ignoreLayout
.
Update
method or coroutines attachedRectTransform
, so it can be used in objects with a Canvas
component directlyRectTransform
: the script detects where your rect overlaps with the Safe Area and updates accordinglyIgnoreSafeArea
component or LayoutElement
with Ignore Layout
marked as true.
Useful for background images, for example.SafeAreaLayoutGroup
's inspector while hovering the Hover to Preview Layout
button or while in Play Mode.
All Preview Modes support both portrait and landscape resolutions.
Screen.safeArea
Preview Mode is only applied when using Unity's Device Simulator (in Unity 2020 and older, available as an UPM package)Screen Space - Overlay
or Screen Space - Camera
modes, so World Space
canvases are ignoredEither:
Install using openupm:
openupm add com.gilzoide.safe-area-layout
Install via Unity Package Manager using the following git URL:
https://github.com/gilzoide/unity-safe-area-layout.git#1.0.2
Clone this repository directly to your Packages
folder or anywhere inside your project's Assets
.
A sample scene is available at Samples~/SimpleSample.
Canvas
components are supported.
Direct children will have their anchors driven while the script is enabled.IgnoreSafeArea
component to them.
Alternatively, use LayoutElement
components with the Ignore Layout
flag marked as true.Hover to Preview Layout
button in the SafeAreaLayoutGroup
's inspector.