Unity3D:添加设备

这篇具有很好参考价值的文章主要介绍了Unity3D:添加设备。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

Unity3D:添加设备

Unity3D:添加设备

推荐:将NSDT场景编辑器加入你的3D工具链

3D工具集:NSDT简石数字孪生

添加设备

若要将新设备添加到设备模拟器,请创建设备定义和设备覆盖。

设备定义是 Unity 项目中扩展名的文本文件。它包含描述设备属性的 JSON。.device

设备覆盖是包含设备屏幕边框的图像,以及凹口、打孔和屏幕矩形的任何其他添加。您可以选择将其与设备定义一起使用,以可视化硬件元素如何阻碍设备屏幕,并确定触摸输入何时因此失败。

创建设备定义

设备定义是表示设备的 JSON 文件。它既有必需的属性,也有一些可选属性。如果设备定义文件包含任何错误,则当您选择该文件时,这些错误将显示在检查器中。

图式

属性 必填 描述
友好名称 要在此设备的 UI 中显示的名称。
版本 指示设备定义文件的版本。目前,版本为 .1
屏幕 对象列表,每个对象描述要模拟设备的屏幕。这必须至少包含一个屏幕。有关每个屏幕对象的架构的信息,请参阅屏幕。
系统信息 描述设备功能的对象。此对象中的值映射到系统信息。有关 systemInfo 对象的架构的信息,请参阅 systemInfo。
屏幕
属性 必填 描述
宽度 屏幕的宽度(以像素为单位)。
高度 屏幕的高度(以像素为单位)。
导航栏高度 屏幕 Android 导航栏的高度(以像素为单位),该栏在某些设备上未全屏显示时显示。
新闻部 屏幕的 dpi。
指引 每个对象描述屏幕可以模拟的方向的对象列表。如果未为此属性设置值,则屏幕支持所有方向。有关每个方向对象的架构的信息,请参阅方向。
介绍 描述设备覆盖的对象。有关此对象的架构的信息,请参阅演示文稿。
取向
属性 必填 描述
取向 屏幕方向。此属性的值是映射到屏幕方向枚举的数字。
安全区域 确定屏幕安全区域的矩形。如果未为此属性设置值,模拟器将假定整个屏幕是安全的。
切口 Rect的列表,用于指定无法显示内容的屏幕区域。
介绍
属性 必填 描述
覆盖路径 从设备定义文件到要用作设备覆盖的映像的相对路径。
边框大小 从叠加到屏幕开始位置的距离(以像素为单位)。
系统信息

此对象中的属性描述设备的功能和系统信息。由于它们描述系统信息,因此其中许多映射到系统信息中的属性。

属性 必填 描述
设备型号 请参阅 Device.SystemInfo.deviceModel。
设备类型 请参阅 Device.SystemInfo.deviceType。
操作系统 请参阅设备.系统信息.操作系统。
操作系统家族 请参阅 Device.SystemInfo.operatingSystemFamily。
处理器计数 请参阅 Device.SystemInfo.processorCount。
处理器频率 请参阅 Device.SystemInfo.processorFrequency。
处理器类型 请参阅 Device.SystemInfo.processorType。
支持加速度计 请参阅 Device.SystemInfo.supportsAccelerometer。
支持音频 请参阅 Device.SystemInfo.supportsAudio。
支持陀螺仪 请参阅 Device.SystemInfo.supportsGyroscope。
支持定位服务 请参阅 Device.SystemInfo.supportsLocationService。
支撑振动 请参阅设备.系统信息.支持振动。
系统内存大小 请参阅 Device.SystemInfo.systemMemorySize。
不支持的标识符 请参阅 Device.SystemInfo.unsupportedIdentifier。
图形依赖数据 每个对象描述设备支持的图形 API 的对象列表。有关每个对象的架构的信息,请参阅 graphicsDependentData。
图形依赖数据

对象中的属性描述设备支持的图形 API。

属性 必填 描述
图形设备类型 请参阅 Device.SystemInfo.graphicsDeviceType。
图形内存大小 请参阅 Device.SystemInfo.graphicsMemorySize。
图形设备名称 请参阅 Device.SystemInfo.graphicsDeviceName。
图形设备供应商 请参阅 Device.SystemInfo.graphicsDeviceVendor。
图形设备标识 请参阅 Device.SystemInfo.graphicsDeviceID。
graphicsDeviceVendorID 请参阅 Device.SystemInfo.graphicsDeviceVendorID。
图形UV馅饼在顶部 请参阅 Device.SystemInfo.graphicsUVStartsAtTop。
图形设备版本 请参阅 Device.SystemInfo.graphicsDeviceVersion。
图形着色器级别 请参阅 Device.SystemInfo.graphicsShaderLevel。
图形多线程 请参阅 Device.SystemInfo.graphicsMultiThreaded。
渲染线程模式 请参阅 Device.SystemInfo.renderingThreadingMode。
hasHiddenSurfaceRemovalOnGPU 请参阅 Device.SystemInfo.hasHiddenSurfaceRemovalOnGPU。
hasDynamicUniformArrayIndexingInFragmentShaders 请参阅 Device.SystemInfo.hasDynamicUniformArrayIndexingInFragmentShaders。
支持阴影 请参阅 Device.SystemInfo.supportsShadows。
支持原始阴影深度采样 请参阅 Device.SystemInfo.supportsRawShadowDepthSampling。
支持运动矢量 请参阅 Device.SystemInfo.supportsMotionVectors。
支持3DTextures 请参阅 Device.SystemInfo.supports3DTextures。
支持2DArrayTextures 请参阅 Device.SystemInfo.supports2DArrayTextures。
支持3DRender纹理 请参阅 Device.SystemInfo.supports3DRenderTextures。
支持立方体地图数组纹理 请参阅 Device.SystemInfo.supportsCubemapArrayTextures。
复制纹理支持 请参阅 Device.SystemInfo.copyTextureSupport。
支持计算着色器 请参阅 Device.SystemInfo.supportsComputeShaders。
支持几何着色器 请参阅 Device.SystemInfo.supportsGeometryShaders。
支持TessellationShaders 请参阅 Device.SystemInfo.supportsTessellationShaders。
支持实例化 请参阅 Device.SystemInfo.supportsInstancing。
支持硬件四拓扑 请参阅 Device.SystemInfo.supportsHardwareQuadTopology。
支持32位索引缓冲区 请参阅 Device.SystemInfo.supports32bitsIndexBuffer。
支持稀疏纹理 请参阅 Device.SystemInfo.supportsSparseTextures。
支持的渲染目标计数 请参阅 Device.SystemInfo.supportedRenderTargetCount。
supportsSepardRenderTargetsBlend 请参阅 Device.SystemInfo.supportsSepardRenderTargetsBlend。
支持的随机写入目标计数 请参阅 Device.SystemInfo.supportedRandomWriteTargetCount。
支持多重采样纹理 请参阅 Device.SystemInfo.supportsMultisampledTextures。
支持多采样自动解析 请参阅 Device.SystemInfo.supportsMultisampleAutoResolve。
支持纹理包装镜像一次 请参阅 Device.SystemInfo.supportsTextureWrapMirrorOnce。
用途反转ZBuffer 请参阅 Device.SystemInfo.usesReversedZBuffer。
npot支持 请参阅 Device.SystemInfo.npotSupport。
最大纹理大小 请参阅 Device.SystemInfo.maxTextureSize。
最大立方体地图大小 请参阅 Device.SystemInfo.maxCubemapSize。
maxComputeBufferInputsVertex 请参阅 Device.SystemInfo.maxComputeBufferInputsVertex。
maxComputeBufferInputsFragment 请参阅 Device.SystemInfo.maxComputeBufferInputsFragment。
maxComputeBufferInputsGeometry 请参阅 Device.SystemInfo.maxComputeBufferInputsGeometry。
maxComputeBufferInputsDomain 请参阅 Device.SystemInfo.maxComputeBufferInputsDomain。
maxComputeBufferInputsHull 请参阅 Device.SystemInfo.maxComputeBufferInputsHull。
maxComputeBufferInputsCompute 请参阅 Device.SystemInfo.maxComputeBufferInputsCompute。
最大计算工作组大小 请参阅 Device.SystemInfo.maxComputeWorkGroupSize。
maxComputeWorkGroupSizeX 请参阅 Device.SystemInfo.maxComputeWorkGroupSizeX。
maxComputeWorkGroupSizeY 请参阅 Device.SystemInfo.maxComputeWorkGroupSizeY。
maxComputeWorkGroupSizeZ 请参阅 Device.SystemInfo.maxComputeWorkGroupSizeZ。
支持异步计算 请参阅 Device.SystemInfo.supportsAsyncCompute。
支持图形围栏 请参阅 Device.SystemInfo.supportsGraphicsFence。
支持AsyncGPUReadback 请参阅 Device.SystemInfo.supportsAsyncGPUReadback。
支持光线追踪 请参阅 Device.SystemInfo.supportsRayTracing。
支持设置常量缓冲区 请参阅 Device.SystemInfo.supportsSetConstantBuffer。
hasMipMaxLevel 请参阅 Device.SystemInfo.hasMipMaxLevel。
支持MipStreaming 请参阅 Device.SystemInfo.supportsMipStreaming。
usesLoadStoreActions 请参阅 Device.SystemInfo.usesLoadStoreActions。
最少的设备定义

以下设备定义包含每个必需属性,不包含可选属性。这是您可以拥有的最低设备定义。

注意:此设备定义不提供方向数据,因此模拟器假定设备支持所有方向,并且安全区域覆盖整个屏幕。

{
    "friendlyName": "Minimal Device",
    "version": 1,
    "screens": [
        {
            "width": 1080,
            "height": 1920,
            "dpi": 450.0
        }
    ],
    "systemInfo": {
        "operatingSystem": "Android"
    }
}
完整的设备定义

以下设备定义包含每个必需属性和可选属性。

{
    "friendlyName": "Apple iPhone XR",
    "version": 1,
    "screens": [
        {
            "width": 828,
            "height": 1792,
            "navigationBarHeight": 0,
            "dpi": 326.0,
            "orientations": [
                {
                    "orientation": 1,
                    "safeArea": {
                        "serializedVersion": "2",
                        "x": 0.0,
                        "y": 68.0,
                        "width": 828.0,
                        "height": 1636.0
                    },
                    "cutouts": [
                        {
                            "serializedVersion": "2",
                            "x": 184.0,
                            "y": 1726.0,
                            "width": 460.0,
                            "height": 66.0
                        }
                    ]
                },
                {
                    "orientation": 3,
                    "safeArea": {
                        "serializedVersion": "2",
                        "x": 88.0,
                        "y": 42.0,
                        "width": 1616.0,
                        "height": 786.0
                    },
                    "cutouts": [
                        {
                            "serializedVersion": "2",
                            "x": 0.0,
                            "y": 184.0,
                            "width": 66.0,
                            "height": 460.0
                        }
                    ]
                },
                {
                    "orientation": 4,
                    "safeArea": {
                        "serializedVersion": "2",
                        "x": 88.0,
                        "y": 42.0,
                        "width": 1616.0,
                        "height": 786.0
                    },
                    "cutouts": [
                        {
                            "serializedVersion": "2",
                            "x": 1726.0,
                            "y": 184.0,
                            "width": 66.0,
                            "height": 460.0
                        }
                    ]
                }
            ],
            "presentation": {
                "overlayPath": "Apple iPhone 11_Overlay.png",
                "borderSize": {
                    "x": 51.0,
                    "y": 51.0,
                    "z": 51.0,
                    "w": 51.0
                }
            }
        }
    ],
    "systemInfo": {
        "deviceModel": "iPhone11,8",
        "deviceType": 1,
        "operatingSystem": "iOS 12.0",
        "operatingSystemFamily": 0,
        "processorCount": 6,
        "processorFrequency": 0,
        "processorType": "arm64e",
        "supportsAccelerometer": true,
        "supportsAudio": true,
        "supportsGyroscope": true,
        "supportsLocationService": true,
        "supportsVibration": true,
        "systemMemorySize": 2813,
        "unsupportedIdentifier": "n/a",
        "graphicsDependentData": [
            {
                "graphicsDeviceType": 16,
                "graphicsMemorySize": 1024,
                "graphicsDeviceName": "Apple A12 GPU",
                "graphicsDeviceVendor": "Apple",
                "graphicsDeviceID": 0,
                "graphicsDeviceVendorID": 0,
                "graphicsUVStartsAtTop": true,
                "graphicsDeviceVersion": "Metal",
                "graphicsShaderLevel": 50,
                "graphicsMultiThreaded": true,
                "renderingThreadingMode": 0,
                "hasHiddenSurfaceRemovalOnGPU": true,
                "hasDynamicUniformArrayIndexingInFragmentShaders": true,
                "supportsShadows": true,
                "supportsRawShadowDepthSampling": true,
                "supportsMotionVectors": true,
                "supports3DTextures": true,
                "supports2DArrayTextures": true,
                "supports3DRenderTextures": true,
                "supportsCubemapArrayTextures": true,
                "copyTextureSupport": 31,
                "supportsComputeShaders": true,
                "supportsGeometryShaders": false,
                "supportsTessellationShaders": true,
                "supportsInstancing": true,
                "supportsHardwareQuadTopology": false,
                "supports32bitsIndexBuffer": true,
                "supportsSparseTextures": false,
                "supportedRenderTargetCount": 8,
                "supportsSeparatedRenderTargetsBlend": true,
                "supportedRandomWriteTargetCount": 8,
                "supportsMultisampledTextures": 1,
                "supportsMultisampleAutoResolve": false,
                "supportsTextureWrapMirrorOnce": 0,
                "usesReversedZBuffer": true,
                "npotSupport": 2,
                "maxTextureSize": 16384,
                "maxCubemapSize": 16384,
                "maxComputeBufferInputsVertex": 8,
                "maxComputeBufferInputsFragment": 8,
                "maxComputeBufferInputsGeometry": 0,
                "maxComputeBufferInputsDomain": 8,
                "maxComputeBufferInputsHull": 8,
                "maxComputeBufferInputsCompute": 8,
                "maxComputeWorkGroupSize": 1024,
                "maxComputeWorkGroupSizeX": 1024,
                "maxComputeWorkGroupSizeY": 1024,
                "maxComputeWorkGroupSizeZ": 1024,
                "supportsAsyncCompute": false,
                "supportsGraphicsFence": true,
                "supportsAsyncGPUReadback": true,
                "supportsRayTracing": false,
                "supportsSetConstantBuffer": true,
                "hasMipMaxLevel": true,
                "supportsMipStreaming": true,
                "usesLoadStoreActions": true,
                "supportedTextureFormats": [1, 2, 3, 4, 5],
                "supportedRenderTextureFormats": [1, 2, 3, 4, 5],
                "ldrGraphicsFormat": 59,
                "hdrGraphicsFormat": 74
            }
        ]
    }
}

创建设备覆盖

设备覆盖是包含设备屏幕边框和其他功能(如凹口、打孔和屏幕矩形的任何其他添加)的图像。您可以选择将其与设备定义一起使用,以可视化硬件元素如何阻碍设备屏幕,并确定触摸输入何时因此失败。

设备模拟器将透明像素解释为可以点击的屏幕区域,将任何其他颜色的不透明像素解释为硬件遮挡的区域。纹理本身可以是任何形状。

以下示例显示了两种 iPhone 机型的设备叠加。

注意:为了模拟使用设备叠加时看到的内容,这些示例在屏幕区域显示 Unity 的默认天空盒,您可以在其中按 tab 键显示。在实际设备叠加中,这些像素应该是透明的。

苹果 IPHONE 8 叠加层 苹果苹果IPHONE XS叠加层
Unity3D:添加设备

Unity3D:添加设备

使用设备覆盖

创建设备覆盖纹理后,若要将其与设备定义一起使用,必须先将设备覆盖纹理文件导入到项目中。

注意:当设备模拟器加载设备覆盖纹理时,它会尝试为其启用读/写。如果无法做到这一点,设备模拟器将显示纹理,但无法使用纹理来屏蔽输入。这意味着,如果单击设备覆盖应屏蔽的凹口和屏幕其他区域,设备模拟器将检测输入。为确保不会发生这种情况,导入设备叠加纹理时,请在纹理导入设置窗口中启用读/写

当设备覆盖纹理位于项目中时,打开设备定义文件,并在定义设备支持的屏幕的对象中添加演示文稿属性。在这里,设置图像文件的路径 () 和边框的大小 ()。有关如何执行此操作的示例,请参阅以下设备定义文件:overlayPathborderSize

{
    "friendlyName": "Minimal Device with Overlay",
    "version": 1,
    "screens": [
        {
            "width": 1080,
            "height": 1920,
            "dpi": 450.0,
            "presentation": {
                "overlayPath": "Overlays/MinimalDeviceOverlay.png",
                "borderSize": {
                    "x": 51.0,
                    "y": 51.0,
                    "z": 51.0,
                    "w": 130.0
                }
            }
        }
    ],
    "systemInfo": {
        "operatingSystem": "Android"
    }
}

: 设备叠加纹理文件的路径可以相对于设备定义文件,也可以相对于 Unity 项目中包含资源目录的目录。例如,如果设备定义文件位于资产/设备目录中,设备覆盖文件位于资产/设备/覆盖目录中,则以下文件路径均有效:

  • 相对于设备定义文件:覆盖/最小设备覆盖.png
  • 相对于包含资产目录的目录:资产/设备/覆盖/最小设备覆盖.png

此文由3D建模学习工作室整理翻译,转载请注明出处!

上一篇:Unity3D:模拟类 (mvrlink.com)

下一篇:Unity3D:扩展设备模拟器 (mvrlink.com)文章来源地址https://www.toymoban.com/news/detail-499320.html

到了这里,关于Unity3D:添加设备的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

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

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

相关文章

  • 【Unity3D】缩放、平移、旋转场景

    1 前言         场景缩放、平移、旋转有两种实现方案,一种是对场景中所有物体进行同步变换,另一种方案是对相机的位置和姿态进行变换。         对于方案一,如果所有物体都在同一个根对象下(其子对象或孙子对象),那么只需要对根对象施加变换就可以实现场景变

    2023年04月22日
    浏览(35)
  • Unity3D实现给3D物体添加文本标签

    本教程将向您展示如何通过编写脚本来实现在Unity3D中给3D物体添加文本标签的通用方法。了解如何创建文本标签预制体,并通过编写脚本将其添加到3D物体上,以提供更多信息或标识物体。

    2024年02月04日
    浏览(92)
  • Unity3D学习记录02——PloyBrush场景搭建

    首先在Window-Package Manager里面搜索Poly Brush,下载后将URP的Shader样例导入  导入后Asset文件夹下会有Sample的文件夹,在菜单栏 Tools-PolyBrush-PolyBrush Window 打开窗口 这个窗口最上面的五个,第一个是用来调整地形高低的,第二个是进行柔化场景的,第三个是调整颜色的, 第四个可以

    2024年02月08日
    浏览(33)
  • Unity3D:提升场景画面品质&平衡性能优化

    在日常开发中,提升场景画面品质的同时平衡性能优化一直是很重要且头疼的一部分,尤其是当场景类型不同及效果需求不一样时。 所以怎么同时提升场景画面品质和平衡性能优化呢,下面介绍一些适用度高且实用性好的设置。 介绍之前先说一下结论:怎么样才能说的上是

    2024年02月08日
    浏览(34)
  • Unity3D项目之游戏场景小地图制作

    创建一个场景资源,可在asset store资源商店下载,选择心仪场景。 链接:https://assetstore.unity.com/?locale=zh-CN 添加一个对象GameObject,命名为player,子物体包括:主摄像机,角色,后面步骤会添加一个plane。 添加一个地图摄像机,命名为MapCamera。修改属性projection为OrthoGraphic;Size为

    2024年02月11日
    浏览(45)
  • Unity3D在车载导航系统的应用场景浅谈

    Unity3D在车载导航系统的应用场景非常广泛,它可以为车载导航系统带来更加逼真、直观和准确的使用体验。以下是几个具体的应用场景: 3D地图导航:Unity3D的实时3D渲染能力使得车载导航系统可以实现3D地图导航功能。通过Unity3D,可以生成超写实风格的3D地图,提供更加逼真

    2024年01月23日
    浏览(40)
  • Unity3D制作注册登录界面,并实现场景跳转

    效果预览图片: 效果预览视频: 一、新建项目工程 1、打开Unity3D,新建一个项目,将其命名为“Login”。我这里用的版本是Unity2018.4.2f1,不同版本制作过程中的界面可能稍有不同,但是不影响具体功能的实现。 2、可以将样例场景SampleScene重命名为Login,最好做到见名知意。

    2024年02月03日
    浏览(50)
  • Unity3D学习记录01:URP渲染管线以及3D游戏场景设置

    以下内容所使用的版本均为Unity2022.3 先在 Window-Package Manager-Unity Registry 里面搜索添加Universal RP   Unity中,创建渲染管线的方式为Asset文件夹下右键 Create-Readering-URP Asset(with Universal Asset) 会创建以下两个Pipeline:  接着在图中的设置里添加这两个渲染管线(Project Setting在Edit窗口下

    2024年02月08日
    浏览(39)
  • Unity3D教程:触发器实现简单的场景跳转

    首先,需确保有一个想要跳转的目标场景。在本案例中,目标场景是ending。 第一步:创建一个碰撞体,放置在需要的触发场景跳转的位置。 第二步:删除多余的脚本,并且新建自己的脚本: 第三

    2024年02月12日
    浏览(40)
  • 【Unity3D】资源文件 ② ( Unity 中场景文件简介 | 查看场景文件内容 | 场景文件相关操作 | 创建场景 | 打开场景 )

    Unity 编辑器中的 场景文件 是以 \\\" .unity \\\" 为后缀的文件 , 该文件中会记录所有 游戏物体 GameObject , 以及游戏物体的相关数据 , 如下内容都是存储在 场景文件 中的 : 游戏物体 GameObject 节点 : 在 Hierarchy 层级窗口 中 场景文件 下的各个节点 都是游戏物体 , 如 主摄像机 , 光源 , 立

    2024年02月09日
    浏览(39)

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

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

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

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

二维码1

领取红包

二维码2

领红包