unity适配Iphone-X 关于底部白条的处理

//判断手机型号
 bool IsIphoneXDevice = false;
    void Awake()
    {
        string modelStr = SystemInfo.deviceModel;
        #if UNITY_IOS
        // iPhoneX:"iPhone10,3","iPhone10,6"  iPhoneXR:"iPhone11,8"  iPhoneXS:"iPhone11,2"  iPhoneXS Max:"iPhone11,6"
        IsIphoneXDevice = modelStr.Equals("iPhone10,3") ||  modelStr.Equals("iPhone10,6") 
                || modelStr.Equals("iPhone11,8") || modelStr.Equals("iPhone11,2") 
                || modelStr.Equals("iPhone11,6") || modelStr.Equals("iPhone12,1");
        #endif
    }

ios型号大全点击:ios不同型号

iOS dev官方文档提到在iOS 11之后给出了一个供开发者延迟系统手势响应的回调接口:preferredScreenEdgesDeferringSystemGestures。通过分析Unity打包后的Xcode工程,在工程目录Classes->UI->UnityViewControllerBaseiOS.mm:

//原文
- (UIRectEdge)preferredScreenEdgesDeferringSystemGestures
{
    UIRectEdge res = UIRectEdgeNone;
if(UnityGetDeferSystemGesturesTopEdge())
    res |= UIRectEdgeTop;
if(UnityGetDeferSystemGesturesBottomEdge())
    res |= UIRectEdgeBottom;
if(UnityGetDeferSystemGesturesLeftEdge())
    res |= UIRectEdgeLeft;
if(UnityGetDeferSystemGesturesRightEdge())
    res |= UIRectEdgeRight;
return res;
}
//修改后
UIRectEdge res = UIRectEdgeNone;
//if(UnityGetDeferSystemGesturesTopEdge())
    //res |= UIRectEdgeTop;
//if(UnityGetDeferSystemGesturesBottomEdge())
    //res |= UIRectEdgeBottom;
//if(UnityGetDeferSystemGesturesLeftEdge())
    //res |= UIRectEdgeLeft;
//if(UnityGetDeferSystemGesturesRightEdge())
    //res |= UIRectEdgeRight;
    return UIRectEdgeAll;

//修改后进入游戏home默认灰色,上滑唤醒,再滑退回主页面

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值