37 lines
928 B
C#
37 lines
928 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace BF {
|
|
public class SafeAreaManager {
|
|
|
|
private static SafeAreaManager instance;
|
|
public static SafeAreaManager Instance{
|
|
get {
|
|
if (instance == null) {
|
|
instance = new SafeAreaManager();
|
|
}
|
|
return instance;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 得到安全区域
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static Rect GetSafeArea ()
|
|
{
|
|
return Screen.safeArea;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 得到竖屏时的刘海高度
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static float GetNotchScreenHeight()
|
|
{
|
|
Rect rect = GetSafeArea();
|
|
return Screen.height - rect.height - rect.y;
|
|
}
|
|
}
|
|
} |