//判断手机型号
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默认灰色,上滑唤醒,再滑退回主页面