Required packages
Safe Area Tool contains interfaces for the module's functions and implements these functions itself. You don't need any additional packages or tools.
Features
Easy to use:
Just add the component to your project and you're done!
High-Speed:
Engineered and extensively optimized for superior performance.
Support for Unity Device Simulator:
Easily and simply test your Safe Areas in the Unity Engine.
Lightweight Integration:
The API is purposefully designed to minimize unnecessary additions or extra burden on your project.
Components:
Platform support
The Safe Area Tool is a cross-platform solution and is supported on all available platforms.
iOS version:
- Unity 2017.2.1 or higher (needed for Screen.safeArea API)
Android version:
- Unity 2018.4.1 or 2019.1.2 or higher with API level 28 (needed for Android cutout support)
Note
The plugin has the ability to create custom safe areas, so you can use it on any device and any version.
Limitations
Unity Version:
The recommended minimum version of Unity is 2017.2.1+.
Samples
Samples.
Safe Area Tool:
SafeArea_Simple_Start |
An example of a scene that demonstrates how the plugin works with the basic settings. |
SafeArea_Custom_SafeArea |
An example of a scene that demonstrates how the plugin works with the ability to edit the safe area directly on the device. |
Install Safe Area Tool
To install Safe Area Tool, simply import the package into your project.
Note
Make sure that the "Add to embedded binaries" option is enabled (iOS Platform) for the ST_SafeArea.dll library in the editor inspector.
Scene setup
Each Unity scene in your application must have one mandatory GameObject: Safe Area Manager.
The Safe Area Manager script that contains basic information about safe areas and interacts with them. If the object is not on the stage, the safe area will not work properly.
To create a Safe Area Manager, right-click in the Hierarchy window and select one of the following options from the shortcut menu.
Silver Tau > Safe Area Tool > Safe Area Manager
or
Window > Silver Tau > Safe Area Tool > Prepare and check the Safe Area Tool
After adding the Safe Area Tool to the scene, the hierarchy window will look like the one below.
This is the default scene setup, but you can rename or change the parentage of the GameObjects to suit your project's needs.
The Safe Area Tool GameObject and its components play an important role in the project.
Safe Area Manager
This is a manager script that contains basic information about safe areas and interacts with them.
This is a manager script that contains basic information about safe areas and interacts with them.
The Safe Area Tool will help you quickly develop and simulate the Safe Area of a notched device! It is designed to help developers manage the safe area of their displays easily and simply.
You can easily check the result of the plugin in Unity Editor using the Device Simulator.
Examples of use:
Update Safe Areas:
A feature that helps update the safe area based on the device's orientation. Only if the orientation has been changed.
{
private void RefreshSafeAreas()
{
SafeAreaManager.Instance.Refresh();
}
}
Refresh the target Safe Areas:
A feature that helps to update a specific safe area based on the orientation of the device.
{
private void RefreshSafeArea()
{
SafeArea safeArea = new SafeArea();
SafeAreaManager.Instance.Refresh(safeArea);
}
}
Force Refresh of Safe Areas:
A feature that helps update the safe area based on the device's orientation.
{
private void ForceRefreshSafeAreas()
{
SafeAreaManager.Instance.ForceRefresh();
}
}
Change the main SafeArea:
A function that helps to change the offset for current safe area elements.
{
private void ChangeMainSafeArea()
{
var customSafeAreaRect = new CustomSafeAreaRect
{
deviceModel = "iPhone13,3",
rectPortrait = new Vector4(102, 102, 0, 0),
rectLandscape = new Vector4(102, 102, 63, 0)
};
SafeAreaManager.Instance.ChangeCurrentSafeArea(customSafeAreaRect);
}
}
Change the Safe Areas Edges:
A function that helps to change the offset for all safe area elements.
{
private void ChangeAllSafeAreaEdges()
{
var _topArea = true;
var _bottomArea = true;
SafeAreaManager.Instance.ChangeAllSafeAreaEdges(_topArea, _bottomArea);
}
}
Safe Area RectTransform
This is an abstract class that helps create a safe area for a single RectTransform object.
Examples of use:
Create a new Safe Area RectTransform object:
This is an example of a class that is created to control the RectTransform object. You can use it, for example, for objects that are created dynamically and need to use a safe area.
public class SafeAreaObject : SafeAreaRectTransform
{
public override void Start()
{
base.Start();
#if UNITY_EDITOR
Debug.Log("The SafeArea object is initialized.", gameObject);
#endif
}
public override void OnDestroy()
{
base.OnDestroy();
#if UNITY_EDITOR
Debug.Log("The SafeArea object has been destroy.", gameObject);
#endif
}
}
Custom Safe Area Rects Settings
This is a script object that contains settings for custom safe areas. You can easily create custom safe areas for different devices.
Custom settings override the default settings provided by the device.
Tip
An example of a custom Safe area for iPhone 12 Pro:
Note: X - Top, Y - Bottom, Z - Left, W - Right
Device Model: iPhone13,3
Rect Portrait: X = 102, Y = 102, Z = 0, W = 0
Rect Landscape: X = 102, Y = 102, Z = 63, W = 0
Properties:
onlyForScreensWithCutouts |
Use only for screens with cutouts. |
firstAreaForAll |
Use the first area (in Custom Safe Area Rects) for all devices. |
customSafeAreaRects |
List of custom safe area rect. |
Excluded Devices Settings
This is a script object that contains settings for devices that will be excluded from the safe area.
Create your own list of devices that will be excluded from Safe Area Manager.
Tip
An example of excluding an iPhone 12 Pro device for Safe area to a manager:
Device Model: iPhone13,3
Properties:
excludedDevices |
A parameter that provides the current list of excluded devices. |
What's new
Version [1.2.0]
Updated
- SafeArea libs (Android & iOS);
- Optimization of the plugin;
- Documentation;
Fixed
Upgrade guide
All components are fully adaptive to each other.
Changelog
Expand
## [1.2.0] - 2025-05-27
### Updated
- SafeArea libs (Android & iOS);
- Optimization of the plugin;
- Documentation;
### Fixed
- Minor bugs;
## [1.1.0] - 2024-02-07
### Added
- ST_SafeArea (Android & iOS libs);
### Updated
- SafeArea Manager;
- SafeArea lib;
- Examples;
- Optimization of the plugin;
### Fixed
- Minor bugs;
## [1.0.0] - 2023-10-31
### Added
- Release;
Issues
Issues are used to track errors, bugs, etc.
libc++abi: terminating due to uncaught exception of type Il2CppExceptionWrapper
Full description of the error:
warning: Module "/Users/labo/Library/Developer/Xcode/iOS DeviceSupport/iPhone13,3 17.0.3 (21A360)/Symbols/usr/lib/system/libsystem_kernel.dylib" uses triple "arm64e-apple-ios17.0.0", which is not compatible with the target triple "arm64-apple-ios17.0.0". Enabling per-module Swift scratch context.
Cause of the error
This is a fairly common error. The reason for the error is that the Unity Engine temporary files are not written correctly. The solution to the problem is not presented below and is completely safe for your project.
Fix:
To resolve the error, you need to delete the "Library" folder in the project's root folder and restart the Unity project. After that, you can safely build your application.