unity 判断 是手机还是平板

///Check the current device is tablet or not
private void checkTheCurrentDevice()
{
#if UNITY_IPHONE
string deviceModel = SystemInfo.deviceModel.ToLower().Trim();
if(deviceModel.StartsWith("ipad"))
{
bIsTablet = true;
}
else
{
bIsTablet = false;
}
#elif UNITY_ANDROID
float physicScreenSize = Mathf.Sqrt(Screen.width * Screen.width + Screen.height * Screen.height) / Screen.dpi;
if(physicScreenSize >= 7f) //If the screen size is >= 7 inches, it‘s a tablet
{
bIsTablet = true;
}
else
{
bIsTablet = false;
}
#else
bIsTablet = false;
#endif

// bIsTablet = false;
}

unity 判断 是手机还是平板

上一篇:Android Alertdialog之多选对话框


下一篇:自定义对话框