安卓判断:
float physicscreen = Mathf.Sqrt(Screen.width * Screen.width + Screen.height * Screen.height) / Screen.dpi;
if (physicscreen >= 7f)
{
Debug.Log(“安卓平板”);
}else{
Debug.Log(“安卓手机”);
}
ios判断:
string iP_genneration = UnityEngine.iOS.Device.generation.ToString();
if (iP_genneration.Substring(0, 3) == “iPa”)
{
Debug.Log(“苹果平板”);
}else
{
Debug.Log(“苹果手机”);
}
本文介绍了一种通过计算屏幕尺寸和设备型号来判断设备是手机还是平板的方法。对于安卓设备,利用屏幕尺寸和DPI计算物理屏幕大小,若大于7则认为是平板;对于iOS设备,检查设备型号字符串,如包含iPa则判断为iPad。

3609


被折叠的 条评论
为什么被折叠?



