码迷,mamicode.com
首页 > 移动开发 > 详细

Unity区分安卓,苹果是平板还是手机

时间:2018-02-26 11:14:39      阅读:466      评论:0      收藏:0      [点我收藏+]

标签:body   unit   else   sys   model   string   log   hone   bsp   

#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 = UnityEngine.iOS.Device.generation.ToString();  
        //The second Mothod: 
        //string iP_genneration=SystemInfo.deviceModel.ToString();


        if (iP_genneration.Substring(0, 3) == "iPa")
        {
            Debug.Log("苹果平板");
        }
        else
        {
            Debug.Log("苹果手机");
        }
#endif

 

Unity区分安卓,苹果是平板还是手机

标签:body   unit   else   sys   model   string   log   hone   bsp   

原文地址:https://www.cnblogs.com/weiqiangwaideshijie/p/8471697.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!