12345678910111213141516171819 |
- using UnityEngine;
- namespace Plugins.CxShine.SafeArea
- {
- public class SafeAreaTop : MonoBehaviour
- {
- public void Start()
- {
- //计算屏幕顶部异形大小
- var safeAreaOffset = (int)(Screen.height - Screen.safeArea.yMax);
- //UI偏移
- var rectTransform = transform.GetComponent<RectTransform>();
- rectTransform.offsetMax = new Vector2(0, -safeAreaOffset / 2);
- }
- }
- }
|