您的位置:首页 > 移动开发 > Unity3D

Unity如何区分安卓、苹果设备是手机与平板?

2016-02-22 15:34 701 查看
iOS Unity 4.x 版本与Unity 5.x 系统函数略有不同:
Unity 5.x 的方式为:UnityEngine.iOS.Device.generation;
//******************2016.02.22   Bruce_Xu*********************
#if UNITY_ANDROID
float physicscreen = Mathf.Sqrt(Screen.width * Screen.width + Screen.height * Screen.height) / Screen.dpi;
if (physicscreen >= 7f)
{
Debug.Log("安卓平板");
}
else
{
Debug.Log("安卓手机");
}
#elif UNITY_IPHONE
Debug.Log(iPhone.generation);
string iP_genneration = iPhone.generation.ToString();
//The second Mothod:
//string iP_genneration=SystemInfo.deviceModel.ToString();

if (iP_genneration.Substring(0, 3) == "iPa")
{
Debug.Log("苹果平板");
}
else
{
Debug.Log("苹果手机");
}
#endif
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: