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;
}

posted @ 2014-02-21 18:25  火之梦魇  阅读(1805)  评论(0编辑  收藏  举报