Unity iOS包iPhoneX home键变灰 防止点击home条直接退出 类似王者荣耀效果

 打开你的Xcode工程, 在该路径下 : Classes/UI/UnityViewControllerBase+iOS.mm ....  或者直接搜索 UnityViewControllerBase+iOS

cmd + F 搜索 : preferredScreenEdgesDeferringSystemGestures 

修改如下:

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

//- (BOOL)prefersHomeIndicatorAutoHidden
//{
//    return UnityGetHideHomeButton();
//}

  这个时候打包真机测试就好啦!

 

posted @ 2019-07-17 20:41  不够自律的人  阅读(720)  评论(0编辑  收藏  举报