IOS刘海屏的适配

一:

iphoneX/XS的高宽比:2.165,iphoneXR/XSmax的高宽比:2.164

using UnityEngine;

public class GameAdaptation : MonoBehaviour
{
    public Transform[] uis;

    private void Awake()
    {
        //禁止屏幕锁屏
        Screen.sleepTimeout = SleepTimeout.NeverSleep;

        if (Mathf.Abs((Screen.height * 1.0f / Screen.width) - 2.16f) < 0.01f)
        {
            for (int i = 0; i < uis.Length; i++)
            {
                uis[i].localPosition -= new Vector3(0, Screen.height * 0.035f, 0);
            }
        }
    }
}
发布了127 篇原创文章 · 获赞 278 · 访问量 24万+

猜你喜欢

转载自blog.csdn.net/LLLLL__/article/details/103081474