unity 判断当前设备是否是模拟器(安卓)

这篇具有很好参考价值的文章主要介绍了unity 判断当前设备是否是模拟器(安卓)。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

最近有个需求,需要判断当前设备是否是模拟器,网上查了一下,发现基本上都是使用特征字符串进行检索,类似这种:

if (SystemInfo.deviceModel.Contains("Emulator") || SystemInfo.deviceModel.Contains("Android SDK"))
    return true;
if (SystemInfo.deviceName.Contains("Android SDK"))//设备名称的字符串检测
    return true;
if (SystemInfo.deviceType == DeviceType.Unknown && SystemInfo.operatingSystem.Contains("x86"))//当前设备的类型字符串检测
    return true;
if (SystemInfo.processorType.Contains("Intel") || SystemInfo.processorType.Contains("AMD"))//当前设备的CPU类型检测
    return true;
if (SystemInfo.graphicsDeviceName.Contains("Intel") || SystemInfo.graphicsDeviceName.Contains("VBox"))//当前设备的显卡名称检测
    return true;

发现都是不行的,因为现在的模拟器都会伪装==

还有一种方法是使用AndroidJavaClass来调用安卓相关的方法:参考林新发大佬
例如这种:
ps:由于没用安卓相关开发知识,可能只是我写错了

AndroidJavaClass intentClass = new AndroidJavaClass("android.content.Intent");
AndroidJavaObject intentObject = new AndroidJavaObject("android.content.Intent", new object[] { });
intentObject.Call<AndroidJavaObject>("setData", new AndroidJavaObject("android.net.Uri", "tel:" + 123456));

测试了一下,都是没用成功。。。。

最后是在是没法了,只能打印所有的SystemInfo的静态字段查看有什么不同:

text2.text = "SystemInfo.batteryLevel" + ":<color=#ff0000>" + SystemInfo.batteryLevel + "</color>\n" +
"SystemInfo.deviceModel" + ":<color=#FF0000>" + SystemInfo.deviceModel + "</color>\n" +
"SystemInfo.batteryStatus" + ":<color=#FF0000>" + SystemInfo.batteryStatus + "</color>\n" +
"SystemInfo.constantBufferOffsetAlignment" + ":<color=#FF0000>" + SystemInfo.constantBufferOffsetAlignment + "</color>\n" +
"SystemInfo.copyTextureSupport" + ":<color=#FF0000>" + SystemInfo.copyTextureSupport + "</color>\n" +
"SystemInfo.deviceName" + ":<color=#FF0000>" + SystemInfo.deviceName + "</color>\n" +
"SystemInfo.deviceType" + ":<color=#FF0000>" + SystemInfo.deviceType + "</color>\n" +
"SystemInfo.deviceUniqueIdentifier" + ":<color=#FF0000>" + SystemInfo.deviceUniqueIdentifier + "</color>\n" +
"SystemInfo.graphicsDeviceID" + ":<color=#FF0000>" + SystemInfo.graphicsDeviceID + "</color>\n" +
"SystemInfo.graphicsDeviceName" + ":<color=#FF0000>" + SystemInfo.graphicsDeviceName + "</color>\n" +
"SystemInfo.graphicsDeviceType" + ":<color=#FF0000>" + SystemInfo.graphicsDeviceType + "</color>\n" +
"SystemInfo.graphicsDeviceVendor" + ":<color=#FF0000>" + SystemInfo.graphicsDeviceVendor + "</color>\n" +
"SystemInfo.graphicsDeviceVendorID" + ":<color=#FF0000>" + SystemInfo.graphicsDeviceVendorID + "</color>\n" +
"SystemInfo.graphicsDeviceVersion" + ":<color=#FF0000>" + SystemInfo.graphicsDeviceVersion + "</color>\n" +
"SystemInfo.graphicsMemorySize" + ":<color=#FF0000>" + SystemInfo.graphicsMemorySize + "</color>\n" +
"SystemInfo.graphicsMultiThreaded" + ":<color=#FF0000>" + SystemInfo.graphicsMultiThreaded + "</color>\n" +
"SystemInfo.graphicsPixelFillrate" + ":<color=#FF0000>" + SystemInfo.graphicsPixelFillrate + "</color>\n" +
"SystemInfo.graphicsShaderLevel" + ":<color=#FF0000>" + SystemInfo.graphicsShaderLevel + "</color>\n" +
"SystemInfo.graphicsUVStartsAtTop" + ":<color=#FF0000>" + SystemInfo.graphicsUVStartsAtTop + "</color>\n" +
"SystemInfo.hasDynamicUniformArrayIndexingInFragmentShaders" + ":<color=#FF0000>" + SystemInfo.hasDynamicUniformArrayIndexingInFragmentShaders + "</color>\n" +
"SystemInfo.hasHiddenSurfaceRemovalOnGPU" + ":<color=#FF0000>" + SystemInfo.hasHiddenSurfaceRemovalOnGPU + "</color>\n" +
"SystemInfo.hasMipMaxLevel" + ":<color=#FF0000>" + SystemInfo.hasMipMaxLevel + "</color>\n" +
"SystemInfo.hdrDisplaySupportFlags" + ":<color=#FF0000>" + SystemInfo.hdrDisplaySupportFlags + "</color>\n" +
"SystemInfo.maxComputeBufferInputsCompute" + ":<color=#FF0000>" + SystemInfo.maxComputeBufferInputsCompute + "</color>\n" +
"SystemInfo.maxComputeBufferInputsDomain" + ":<color=#FF0000>" + SystemInfo.maxComputeBufferInputsDomain + "</color>\n" +
"SystemInfo.maxComputeBufferInputsFragment" + ":<color=#FF0000>" + SystemInfo.maxComputeBufferInputsFragment + "</color>\n" +
"SystemInfo.maxComputeBufferInputsGeometry" + ":<color=#FF0000>" + SystemInfo.maxComputeBufferInputsGeometry + "</color>\n" +
"SystemInfo.maxComputeBufferInputsHull" + ":<color=#FF0000>" + SystemInfo.maxComputeBufferInputsHull + "</color>\n" +
"SystemInfo.maxComputeBufferInputsVertex" + ":<color=#FF0000>" + SystemInfo.maxComputeBufferInputsVertex + "</color>\n" +
"SystemInfo.maxComputeWorkGroupSize" + ":<color=#FF0000>" + SystemInfo.maxComputeWorkGroupSize + "</color>\n" +
"SystemInfo.maxComputeWorkGroupSizeX" + ":<color=#FF0000>" + SystemInfo.maxComputeWorkGroupSizeX + "</color>\n" +
"SystemInfo.maxComputeWorkGroupSizeY" + ":<color=#FF0000>" + SystemInfo.maxComputeWorkGroupSizeY + "</color>\n" +
"SystemInfo.maxComputeWorkGroupSizeZ" + ":<color=#FF0000>" + SystemInfo.maxComputeWorkGroupSizeZ + "</color>\n" +
"SystemInfo.maxCubemapSize" + ":<color=#FF0000>" + SystemInfo.maxCubemapSize + "</color>\n" +
"SystemInfo.maxTextureSize" + ":<color=#FF0000>" + SystemInfo.maxTextureSize + "</color>\n" +
"SystemInfo.minConstantBufferOffsetAlignment" + ":<color=#FF0000>" + SystemInfo.minConstantBufferOffsetAlignment + "</color>\n" +
"SystemInfo.npotSupport" + ":<color=#FF0000>" + SystemInfo.npotSupport + "</color>\n" +
"SystemInfo.operatingSystem" + ":<color=#FF0000>" + SystemInfo.operatingSystem + "</color>\n" +
"SystemInfo.operatingSystemFamily" + ":<color=#FF0000>" + SystemInfo.operatingSystemFamily + "</color>\n" +
"SystemInfo.processorCount" + ":<color=#FF0000>" + SystemInfo.processorCount + "</color>\n" +
"SystemInfo.processorFrequency" + ":<color=#FF0000>" + SystemInfo.processorFrequency + "</color>\n" +
"SystemInfo.processorType" + ":<color=#FF0000>" + SystemInfo.processorType + "</color>\n" +
"SystemInfo.renderingThreadingMode" + ":<color=#FF0000>" + SystemInfo.renderingThreadingMode + "</color>\n" +
"SystemInfo.supportedRandomWriteTargetCount" + ":<color=#FF0000>" + SystemInfo.supportedRandomWriteTargetCount + "</color>\n" +
"SystemInfo.supportedRenderTargetCount" + ":<color=#FF0000>" + SystemInfo.supportedRenderTargetCount + "</color>\n" +
"SystemInfo.supports2DArrayTextures" + ":<color=#FF0000>" + SystemInfo.supports2DArrayTextures + "</color>\n" +
"SystemInfo.supports32bitsIndexBuffer" + ":<color=#FF0000>" + SystemInfo.supports32bitsIndexBuffer + "</color>\n" +
"SystemInfo.supports3DRenderTextures" + ":<color=#FF0000>" + SystemInfo.supports3DRenderTextures + "</color>\n" +
"SystemInfo.supports3DTextures" + ":<color=#FF0000>" + SystemInfo.supports3DTextures + "</color>\n" +
"SystemInfo.supportsAccelerometer" + ":<color=#FF0000>" + SystemInfo.supportsAccelerometer + "</color>\n" +
"SystemInfo.supportsAsyncCompute" + ":<color=#FF0000>" + SystemInfo.supportsAsyncCompute + "</color>\n" +
"SystemInfo.supportsAsyncGPUReadback" + ":<color=#FF0000>" + SystemInfo.supportsAsyncGPUReadback + "</color>\n" +
"SystemInfo.supportsAudio" + ":<color=#FF0000>" + SystemInfo.supportsAudio + "</color>\n" +
"SystemInfo.supportsCompressed3DTextures" + ":<color=#FF0000>" + SystemInfo.supportsCompressed3DTextures + "</color>\n" +
"SystemInfo.supportsComputeShaders" + ":<color=#FF0000>" + SystemInfo.supportsComputeShaders + "</color>\n" +
"SystemInfo.supportsConservativeRaster" + ":<color=#FF0000>" + SystemInfo.supportsConservativeRaster + "</color>\n" +
"SystemInfo.supportsCubemapArrayTextures" + ":<color=#FF0000>" + SystemInfo.supportsCubemapArrayTextures + "</color>\n" +
"SystemInfo.supportsGeometryShaders" + ":<color=#FF0000>" + SystemInfo.supportsGeometryShaders + "</color>\n" +
"SystemInfo.supportsGpuRecorder" + ":<color=#FF0000>" + SystemInfo.supportsGpuRecorder + "</color>\n" +
"SystemInfo.supportsGraphicsFence" + ":<color=#FF0000>" + SystemInfo.supportsGraphicsFence + "</color>\n" +
"SystemInfo.supportsGyroscope" + ":<color=#FF0000>" + SystemInfo.supportsGyroscope + "</color>\n" +
"SystemInfo.supportsHardwareQuadTopology" + ":<color=#FF0000>" + SystemInfo.supportsHardwareQuadTopology + "</color>\n" +
"SystemInfo.supportsImageEffects" + ":<color=#FF0000>" + SystemInfo.supportsImageEffects + "</color>\n" +
"SystemInfo.supportsInstancing" + ":<color=#FF0000>" + SystemInfo.supportsInstancing + "</color>\n" +
"SystemInfo.supportsLocationService" + ":<color=#FF0000>" + SystemInfo.supportsLocationService + "</color>\n" +
"SystemInfo.supportsMipStreaming" + ":<color=#FF0000>" + SystemInfo.supportsMipStreaming + "</color>\n" +
"SystemInfo.supportsMotionVectors" + ":<color=#FF0000>" + SystemInfo.supportsMotionVectors + "</color>\n" +
"SystemInfo.supportsMultisampleAutoResolve" + ":<color=#FF0000>" + SystemInfo.supportsMultisampleAutoResolve + "</color>\n" +
"SystemInfo.supportsMultisampled2DArrayTextures" + ":<color=#FF0000>" + SystemInfo.supportsMultisampled2DArrayTextures + "</color>\n" +
"SystemInfo.supportsMultisampledTextures" + ":<color=#FF0000>" + SystemInfo.supportsMultisampledTextures + "</color>\n" +
"SystemInfo.supportsMultiview" + ":<color=#FF0000>" + SystemInfo.supportsMultiview + "</color>\n" +
"SystemInfo.supportsRawShadowDepthSampling" + ":<color=#FF0000>" + SystemInfo.supportsRawShadowDepthSampling + "</color>\n" +
"SystemInfo.supportsRayTracing" + ":<color=#FF0000>" + SystemInfo.supportsRayTracing + "</color>\n" +
"SystemInfo.supportsRenderTargetArrayIndexFromVertexShader" + ":<color=#FF0000>" + SystemInfo.supportsRenderTargetArrayIndexFromVertexShader + "</color>\n" +
"SystemInfo.supportsRenderTextures" + ":<color=#FF0000>" + SystemInfo.supportsRenderTextures + "</color>\n" +
"SystemInfo.supportsRenderToCubemap" + ":<color=#FF0000>" + SystemInfo.supportsRenderToCubemap + "</color>\n" +
"SystemInfo.supportsSeparatedRenderTargetsBlend" + ":<color=#FF0000>" + SystemInfo.supportsSeparatedRenderTargetsBlend + "</color>\n" +
"SystemInfo.supportsSetConstantBuffer" + ":<color=#FF0000>" + SystemInfo.supportsSetConstantBuffer + "</color>\n" +
"SystemInfo.supportsShadows" + ":<color=#FF0000>" + SystemInfo.supportsShadows + "</color>\n" +
"SystemInfo.supportsSparseTextures" + ":<color=#FF0000>" + SystemInfo.supportsSparseTextures + "</color>\n" +
"SystemInfo.supportsStencil" + ":<color=#FF0000>" + SystemInfo.supportsStencil + "</color>\n" +
"SystemInfo.supportsTessellationShaders" + ":<color=#FF0000>" + SystemInfo.supportsTessellationShaders + "</color>\n" +
"SystemInfo.supportsTextureWrapMirrorOnce" + ":<color=#FF0000>" + SystemInfo.supportsTextureWrapMirrorOnce + "</color>\n" +
"SystemInfo.supportsVertexPrograms" + ":<color=#FF0000>" + SystemInfo.supportsVertexPrograms + "</color>\n" +
"SystemInfo.supportsVibration" + ":<color=#FF0000>" + SystemInfo.supportsVibration + "</color>\n" +
"SystemInfo.systemMemorySize" + ":<color=#FF0000>" + SystemInfo.systemMemorySize + "</color>\n" +
"SystemInfo.usesLoadStoreActions" + ":<color=#FF0000>" + SystemInfo.usesLoadStoreActions + "</color>\n" +
"SystemInfo.usesReversedZBuffer" + ":<color=#FF0000>" + SystemInfo.usesReversedZBuffer + "</color>";

最后发现在模拟器上面:

SystemInfo.graphicsDeviceID = 0;
SystemInfo.graphicsDeviceVendorID = 0;

在手机上面测试是有值的
还有一个这个方法:获取设备固件版本号

public string IsRunningOnEmulator6()
{
    if (Application.platform == RuntimePlatform.Android)
    {
        AndroidJavaClass buildClass = new AndroidJavaClass("android.os.Build");
        string radioVersion = buildClass.CallStatic<string>("getRadioVersion");
        return radioVersion;
    }
    return "";
}

这个也是在手机上面有,模拟器上面是没有的
最后附上模拟器打印的参数:
unity 判断是否是模拟器,unity,android,unity,游戏引擎文章来源地址https://www.toymoban.com/news/detail-626742.html

到了这里,关于unity 判断当前设备是否是模拟器(安卓)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 【Unity 实用工具篇】✨ | UI适配神器 Device Simulator 移动设备模拟器 的详细使用方法

    前言 今天带来的是Unity提供的一个设备模拟器 Device Simulator 。 它可以帮助开发者在编辑器中模拟出移动端的环境,直接进行测试。 所有操作都可以在编辑器上进行#

    2024年02月14日
    浏览(46)
  • 避免检测:安卓模拟器/安卓虚拟机/root环境

    如果你想要避免某些安卓应用检测到你正在使用安卓虚拟机,你可以尝试以下方法。但请注意,这些操作可能违反了应用的使用条款,因此请在遵守相关法规和条款的前提下进行操作。 修改虚拟机设备信息:一些应用会检查设备的制造商、型号等信息。你可以使用一些工具来

    2024年02月12日
    浏览(44)
  • M芯片Mac上最好用的安卓模拟器「MuMu模拟器Pro」正式发布!

    MuMu模拟器 Pro: MuMu模拟器 Pro是网 易专为Mac电脑用户开发的一款安卓模拟器产品,致力于为用户提供流畅的安卓应用和游戏体验。针对Apple M系列芯片进行了优化,为Mac用户带来更加顺畅的安卓系统使用体验。本文将全面从获取流程、使用 场景、性能、功能界面等方面对 MuM

    2024年02月20日
    浏览(65)
  • Charles 电脑/安卓12模拟器证书配置

    一、安装Charles 官网下载:Download a Free Trial of Charles • Charles Web Debugging Proxy (charlesproxy.com) 破解令牌:Charles破解工具 (zzzmode.com) 1.1 破解令牌使用 二、Charles配置 2.1 修改https 代理设置 port 设置为自己喜欢的并且为占用的端口号 2.2 安装证书(电脑) 2.3 安装证书(安卓模拟器)

    2024年01月23日
    浏览(50)
  • uniapp 安装安卓、IOS模拟器并调试

    一、安装Android模拟器并调试 1.下载并安装Android Studio。 2.创建简单project。 3.安装模拟器。  完成安卓模拟器的安装。 4.启动模拟器。 5.hbuilderx选择模拟器、运行。 点击刷新按钮后出现模拟器,勾选并运行。 6.调试。 在  HBuilderX  中,项目启动后,在下方的控制台选择  deb

    2024年04月25日
    浏览(39)
  • Android Studio安卓手机模拟器环境搭建

    1、以管理员身份启动命令提示符工具 2、清理旧环境  2、解压缩文件夹内提供的JDK 11(一定是11,不能是其它版本,如果前面已经安装过JDK8,需要先在控制面板中卸载JDK8,并且删除环境变量JAVA_HOME,以及删除环境变量Path中涉及到JDK8的内容;重启后安装JDK11)     将JDK解压

    2024年02月09日
    浏览(51)
  • mac m1系统安装安卓手机模拟器

    背景:本人是一名开发人员,本地小程序上的需要地图导航到手机上,所以找到一个mac(m1)安装安卓模拟器的方案,这里记录分享一下。 废话不多说直接上步骤,很详细跟着步骤走就能完成!!! 相关资源(边下载边看下面内容): 1.华为应用市场安装包(链接: https://p

    2024年02月05日
    浏览(55)
  • M芯片Mac实现安卓模拟器多开

    写在前面:博主是一只经过实战开发历练后投身培训事业的“小山猪”,昵称取自动画片《狮子王》中的“彭彭”,总是以乐观、积极的心态对待周边的事物。本人的技术路线从Java全栈工程师一路奔向大数据开发、数据挖掘领域,如今终有小成,愿将昔日所获与大家交流一二

    2024年02月12日
    浏览(46)
  • Hyper-V与安卓模拟器不共存

    一是某些新的模拟器已经开始使用新接口开发,支持了共存,安装这种新的安卓模拟器即可。 对于不支持共存的模拟器,只得增加一个windows开机后的系统选项,如果需要切换这两种不同选项使用系统,每次切换都需要重启windows系统: 增加选项的设置如下: 由于Windows中Hyp

    2024年02月08日
    浏览(42)
  • Mac搭建安卓模拟器(支持M1/M2)

    最近在研究Vue打包成app,给我的报价器搞一个移动端,奈何没有安卓手机用于测试。所以想到安装一个安卓模拟器。 看了下目前主流的安卓模拟器基本都不支持Mac版本。网易的mumu目前来看还是只支持Intel芯。 下载地址:https://www.aliyundrive.com/s/NZet5jrKxV4 下载完成后将后缀 .mp

    2024年02月16日
    浏览(40)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包