[Unity] unity如何判断设备型号

查看:555 |回复:5 | 2021-2-23 18:12:31

您需要 登录 才可以下载或查看,没有账号?注册

x
本帖最后由 源数之力 于 2021-3-2 14:35 编辑

unity如何判断设备型号
2021-2-23 18:12:31  
 赞 赞 0

使用道具 登录

5个回答,把该问题分享到群,邀请大神一起回答。
2#


  • 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);



  •     }



  • }



回复 收起回复
2021-2-23 18:25:20   回复
 赞 赞 1

使用道具 登录

3#
楼上的回答太专业了吧
回复 收起回复
2021-8-28 08:03:48   回复
 赞 赞 2

使用道具 登录

4#
在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
回复 收起回复
2021-8-28 12:39:48   回复
 赞 赞 1

使用道具 登录

5#
感谢大佬们的回答  学习了  这个我真不懂
回复 收起回复
2021-12-25 12:10:48   回复
 赞 赞 1

使用道具 登录

6#
回复 收起回复
2023-2-26 12:48:27   回复
 赞 赞 0

使用道具 登录

CG 游戏行业专业问题

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表