20 lines
655 B
C#
20 lines
655 B
C#
using UnityEngine;
|
|
|
|
namespace MagnetismHeroes.UnityRuntime.Presentation
|
|
{
|
|
public sealed class SafeAreaPanel : MonoBehaviour
|
|
{
|
|
private Rect _last;
|
|
private void Update()
|
|
{
|
|
var area = Screen.safeArea;
|
|
if (_last == area || Screen.width == 0 || Screen.height == 0) return;
|
|
_last = area;
|
|
var rect = (RectTransform)transform;
|
|
rect.anchorMin = area.min / new Vector2(Screen.width, Screen.height);
|
|
rect.anchorMax = area.max / new Vector2(Screen.width, Screen.height);
|
|
rect.offsetMin = Vector2.zero; rect.offsetMax = Vector2.zero;
|
|
}
|
|
}
|
|
}
|