unity如何判断设备型号
本帖最后由 源数之力 于 2021-3-2 14:35 编辑unity如何判断设备型号
[*]using UnityEngine;
[*]
[*]
public class DeviceInfo
[*]
{
[*]
/// <summary>
[*]
/// 获取设备型号
[*]
/// </summary>
[*]
/// <returns></returns>
[*]
public static string CurrentDeviceModel()
[*]
{
[*]
return SystemInfo.deviceModel;// hardware strings
[*]
}
[*]
[*]
/// <summary>
[*]
/// 通过设备型号判断该设备是不是异形屏幕(带刘海),如果是则返回true
[*]
/// </summary>
[*]
/// <returns></returns>
[*]
public static bool Flag_ExternScreen()
[*]
{
[*]
if (CurrentDeviceModel().CompareTo("iPhone10,3") == 0 ||
[*]
CurrentDeviceModel().CompareTo("iPhone10,6") == 0 ||
[*]
CurrentDeviceModel().CompareTo("vivo vivo Y85A") == 0
[*]
)
[*]
{
[*]
return true;
[*]
}
[*]
[*]
return false;
[*]
}
[*]
[*]
/// <summary>
[*]
/// 获取设备的屏幕比例(高宽比)
[*]
/// </summary>
[*]
/// <returns></returns>
[*]
public static int CurrentScreenRatio()
[*]
{
[*]
float ss = (Screen.height * 1.0f) / Screen.width;
[*]
//Debug.Log((int)(ss * 100));
[*]
return (int)(ss * 100);
[*]
}
[*]
}
楼上的回答太专业了吧 在unity里封装了一个非常好用的类,可以方便的获取设备硬件的相关信息,它就是SystemInfo类
下面列举一些常用的信息
print(SystemInfo.graphicsDeviceID);//获取显卡的唯一标识符
print(SystemInfo.deviceUniqueIdentifier);//获取设备唯一标识符
print(SystemInfo.deviceType);//获取设备的类型
print(SystemInfo.processorType);//获取处理器的类型
————————————————
版权声明:本文为CSDN博主「逍遥小道」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/blastblade/article/details/83061294 感谢大佬们的回答学习了这个我真不懂 {:1_236:}
页:
[1]