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

复制代码
#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
复制代码

 

posted @   围墙外的世界  阅读(951)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示