using UnityEngine; namespace Olympus { [RequireComponent(typeof(RectTransform))] public sealed class SafeArea : MonoBehaviour { Rect last; int width, height; void LateUpdate() { var area = Screen.safeArea; if (area == last && width == Screen.width && height == Screen.height) return; last = area; width = Screen.width; height = Screen.height; if (width < 1 || height < 1) return; var rect = (RectTransform)transform; rect.anchorMin = new Vector2(area.xMin / width, area.yMin / height); rect.anchorMax = new Vector2(area.xMax / width, area.yMax / height); rect.offsetMin = rect.offsetMax = Vector2.zero; } } }