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

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

你可能感兴趣的:(Unity应用)