Unity 普通手机,长屏手机和Pad的分辨

	//设备类型
	public enum GEnumDeviceType
	{
	    None = 0,
	    //长屏手机
	    LongPhone = 1,
	    //普通手机
	    Phone = 1 << 2,
	    //平板
	    Pad = 1 << 3,
	}

	/// 
    /// 屏幕需不需要适配
    /// 
    /// 
    private static GEnumDeviceType CheckDeviceType()
    {
        float scale = (float)Screen.width / Screen.height;

        //return scale < 0.57f;//9:16 == 0.5625
        //Debug.Log(string.Format("Resolution————{0} * {1}  Crown Proportion:{2}", Screen.width, Screen.height, scale));

        if (scale < 0.5625f)
        {
            return GEnumDeviceType.LongPhone;
        }
        else
        {
            float physicScreenSize = Mathf.Sqrt(Screen.width * Screen.width + Screen.height * Screen.height) / Screen.dpi;

            if (physicScreenSize >= 7)
            {
                return GEnumDeviceType.Pad;
            }
            else
            {
                return GEnumDeviceType.Phone;
            }
        }
    }

你可能感兴趣的:(unity,ipad,iphone)