Unity3D:添加設(shè)備
推薦:將NSDT場景編輯器加入你的3D工具鏈
3D工具集:NSDT簡石數(shù)字孿生
添加設(shè)備
若要將新設(shè)備添加到設(shè)備模擬器,請創(chuàng)建設(shè)備定義和設(shè)備覆蓋。
設(shè)備定義是 Unity 項目中擴展名的文本文件。它包含描述設(shè)備屬性的 JSON。.device
設(shè)備覆蓋是包含設(shè)備屏幕邊框的圖像,以及凹口、打孔和屏幕矩形的任何其他添加。您可以選擇將其與設(shè)備定義一起使用,以可視化硬件元素如何阻礙設(shè)備屏幕,并確定觸摸輸入何時因此失敗。
創(chuàng)建設(shè)備定義
設(shè)備定義是表示設(shè)備的 JSON 文件。它既有必需的屬性,也有一些可選屬性。如果設(shè)備定義文件包含任何錯誤,則當(dāng)您選擇該文件時,這些錯誤將顯示在檢查器中。
圖式
屬性 | 必填 | 描述 |
---|---|---|
友好名稱 | 是 | 要在此設(shè)備的 UI 中顯示的名稱。 |
版本 | 是 | 指示設(shè)備定義文件的版本。目前,版本為 .1
|
屏幕 | 是 | 對象列表,每個對象描述要模擬設(shè)備的屏幕。這必須至少包含一個屏幕。有關(guān)每個屏幕對象的架構(gòu)的信息,請參閱屏幕。 |
系統(tǒng)信息 | 是 | 描述設(shè)備功能的對象。此對象中的值映射到系統(tǒng)信息。有關(guān) systemInfo 對象的架構(gòu)的信息,請參閱?systemInfo。 |
屏幕
屬性 | 必填 | 描述 |
---|---|---|
寬度 | 是 | 屏幕的寬度(以像素為單位)。 |
高度 | 是 | 屏幕的高度(以像素為單位)。 |
導(dǎo)航欄高度 | 否 | 屏幕 Android 導(dǎo)航欄的高度(以像素為單位),該欄在某些設(shè)備上未全屏顯示時顯示。 |
新聞部 | 是 | 屏幕的 dpi。 |
指引 | 否 | 每個對象描述屏幕可以模擬的方向的對象列表。如果未為此屬性設(shè)置值,則屏幕支持所有方向。有關(guān)每個方向?qū)ο蟮募軜?gòu)的信息,請參閱方向。 |
介紹 | 否 | 描述設(shè)備覆蓋的對象。有關(guān)此對象的架構(gòu)的信息,請參閱演示文稿。 |
取向
屬性 | 必填 | 描述 |
---|---|---|
取向 | 是 | 屏幕方向。此屬性的值是映射到屏幕方向枚舉的數(shù)字。 |
安全區(qū)域 | 否 | 確定屏幕安全區(qū)域的矩形。如果未為此屬性設(shè)置值,模擬器將假定整個屏幕是安全的。 |
切口 | 否 | Rect的列表,用于指定無法顯示內(nèi)容的屏幕區(qū)域。 |
介紹
屬性 | 必填 | 描述 |
---|---|---|
覆蓋路徑 | 否 | 從設(shè)備定義文件到要用作設(shè)備覆蓋的映像的相對路徑。 |
邊框大小 | 否 | 從疊加到屏幕開始位置的距離(以像素為單位)。 |
系統(tǒng)信息
此對象中的屬性描述設(shè)備的功能和系統(tǒng)信息。由于它們描述系統(tǒng)信息,因此其中許多映射到系統(tǒng)信息中的屬性。
屬性 | 必填 | 描述 |
---|---|---|
設(shè)備型號 | 否 | 請參閱?Device.SystemInfo.deviceModel。 |
設(shè)備類型 | 否 | 請參閱?Device.SystemInfo.deviceType。 |
操作系統(tǒng) | 是 | 請參閱設(shè)備.系統(tǒng)信息.操作系統(tǒng)。 |
操作系統(tǒng)家族 | 否 | 請參閱?Device.SystemInfo.operatingSystemFamily。 |
處理器計數(shù) | 否 | 請參閱?Device.SystemInfo.processorCount。 |
處理器頻率 | 否 | 請參閱?Device.SystemInfo.processorFrequency。 |
處理器類型 | 否 | 請參閱?Device.SystemInfo.processorType。 |
支持加速度計 | 否 | 請參閱?Device.SystemInfo.supportsAccelerometer。 |
支持音頻 | 否 | 請參閱?Device.SystemInfo.supportsAudio。 |
支持陀螺儀 | 否 | 請參閱?Device.SystemInfo.supportsGyroscope。 |
支持定位服務(wù) | 否 | 請參閱?Device.SystemInfo.supportsLocationService。 |
支撐振動 | 否 | 請參閱設(shè)備.系統(tǒng)信息.支持振動。 |
系統(tǒng)內(nèi)存大小 | 否 | 請參閱?Device.SystemInfo.systemMemorySize。 |
不支持的標(biāo)識符 | 否 | 請參閱?Device.SystemInfo.unsupportedIdentifier。 |
圖形依賴數(shù)據(jù) | 否 | 每個對象描述設(shè)備支持的圖形 API 的對象列表。有關(guān)每個對象的架構(gòu)的信息,請參閱?graphicsDependentData。 |
圖形依賴數(shù)據(jù)
對象中的屬性描述設(shè)備支持的圖形 API。
屬性 | 必填 | 描述 |
---|---|---|
圖形設(shè)備類型 | 是 | 請參閱?Device.SystemInfo.graphicsDeviceType。 |
圖形內(nèi)存大小 | 否 | 請參閱?Device.SystemInfo.graphicsMemorySize。 |
圖形設(shè)備名稱 | 否 | 請參閱?Device.SystemInfo.graphicsDeviceName。 |
圖形設(shè)備供應(yīng)商 | 否 | 請參閱?Device.SystemInfo.graphicsDeviceVendor。 |
圖形設(shè)備標(biāo)識 | 否 | 請參閱?Device.SystemInfo.graphicsDeviceID。 |
graphicsDeviceVendorID | 否 | 請參閱?Device.SystemInfo.graphicsDeviceVendorID。 |
圖形UV餡餅在頂部 | 否 | 請參閱?Device.SystemInfo.graphicsUVStartsAtTop。 |
圖形設(shè)備版本 | 否 | 請參閱?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。 |
支持立方體地圖數(shù)組紋理 | 否 | 請參閱?Device.SystemInfo.supportsCubemapArrayTextures。 |
復(fù)制紋理支持 | 否 | 請參閱?Device.SystemInfo.copyTextureSupport。 |
支持計算著色器 | 否 | 請參閱?Device.SystemInfo.supportsComputeShaders。 |
支持幾何著色器 | 否 | 請參閱?Device.SystemInfo.supportsGeometryShaders。 |
支持TessellationShaders | 否 | 請參閱?Device.SystemInfo.supportsTessellationShaders。 |
支持實例化 | 否 | 請參閱?Device.SystemInfo.supportsInstancing。 |
支持硬件四拓撲 | 否 | 請參閱?Device.SystemInfo.supportsHardwareQuadTopology。 |
支持32位索引緩沖區(qū) | 否 | 請參閱?Device.SystemInfo.supports32bitsIndexBuffer。 |
支持稀疏紋理 | 否 | 請參閱?Device.SystemInfo.supportsSparseTextures。 |
支持的渲染目標(biāo)計數(shù) | 否 | 請參閱?Device.SystemInfo.supportedRenderTargetCount。 |
supportsSepardRenderTargetsBlend | 否 | 請參閱?Device.SystemInfo.supportsSepardRenderTargetsBlend。 |
支持的隨機寫入目標(biāo)計數(shù) | 否 | 請參閱?Device.SystemInfo.supportedRandomWriteTargetCount。 |
支持多重采樣紋理 | 否 | 請參閱?Device.SystemInfo.supportsMultisampledTextures。 |
支持多采樣自動解析 | 否 | 請參閱?Device.SystemInfo.supportsMultisampleAutoResolve。 |
支持紋理包裝鏡像一次 | 否 | 請參閱?Device.SystemInfo.supportsTextureWrapMirrorOnce。 |
用途反轉(zhuǎn)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。 |
支持設(shè)置常量緩沖區(qū) | 否 | 請參閱?Device.SystemInfo.supportsSetConstantBuffer。 |
hasMipMaxLevel | 否 | 請參閱?Device.SystemInfo.hasMipMaxLevel。 |
支持MipStreaming | 否 | 請參閱?Device.SystemInfo.supportsMipStreaming。 |
usesLoadStoreActions | 否 | 請參閱?Device.SystemInfo.usesLoadStoreActions。 |
最少的設(shè)備定義
以下設(shè)備定義包含每個必需屬性,不包含可選屬性。這是您可以擁有的最低設(shè)備定義。
注意:此設(shè)備定義不提供方向數(shù)據(jù),因此模擬器假定設(shè)備支持所有方向,并且安全區(qū)域覆蓋整個屏幕。
{
"friendlyName": "Minimal Device",
"version": 1,
"screens": [
{
"width": 1080,
"height": 1920,
"dpi": 450.0
}
],
"systemInfo": {
"operatingSystem": "Android"
}
}
完整的設(shè)備定義
以下設(shè)備定義包含每個必需屬性和可選屬性。
{
"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
}
]
}
}
創(chuàng)建設(shè)備覆蓋
設(shè)備覆蓋是包含設(shè)備屏幕邊框和其他功能(如凹口、打孔和屏幕矩形的任何其他添加)的圖像。您可以選擇將其與設(shè)備定義一起使用,以可視化硬件元素如何阻礙設(shè)備屏幕,并確定觸摸輸入何時因此失敗。
設(shè)備模擬器將透明像素解釋為可以點擊的屏幕區(qū)域,將任何其他顏色的不透明像素解釋為硬件遮擋的區(qū)域。紋理本身可以是任何形狀。
以下示例顯示了兩種 iPhone 機型的設(shè)備疊加。
注意:為了模擬使用設(shè)備疊加時看到的內(nèi)容,這些示例在屏幕區(qū)域顯示 Unity 的默認天空盒,您可以在其中按 tab 鍵顯示。在實際設(shè)備疊加中,這些像素應(yīng)該是透明的。
蘋果 IPHONE 8 疊加層 | 蘋果蘋果IPHONE XS疊加層 |
---|---|
![]() |
|
使用設(shè)備覆蓋
創(chuàng)建設(shè)備覆蓋紋理后,若要將其與設(shè)備定義一起使用,必須先將設(shè)備覆蓋紋理文件導(dǎo)入到項目中。
注意:當(dāng)設(shè)備模擬器加載設(shè)備覆蓋紋理時,它會嘗試為其啟用讀/寫。如果無法做到這一點,設(shè)備模擬器將顯示紋理,但無法使用紋理來屏蔽輸入。這意味著,如果單擊設(shè)備覆蓋應(yīng)屏蔽的凹口和屏幕其他區(qū)域,設(shè)備模擬器將檢測輸入。為確保不會發(fā)生這種情況,導(dǎo)入設(shè)備疊加紋理時,請在紋理導(dǎo)入設(shè)置窗口中啟用讀/寫。
當(dāng)設(shè)備覆蓋紋理位于項目中時,打開設(shè)備定義文件,并在定義設(shè)備支持的屏幕的對象中添加演示文稿屬性。在這里,設(shè)置圖像文件的路徑 () 和邊框的大小 ()。有關(guān)如何執(zhí)行此操作的示例,請參閱以下設(shè)備定義文件: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"
}
}
注: 設(shè)備疊加紋理文件的路徑可以相對于設(shè)備定義文件,也可以相對于 Unity 項目中包含資源或包目錄的目錄。例如,如果設(shè)備定義文件位于資產(chǎn)/設(shè)備目錄中,設(shè)備覆蓋文件位于資產(chǎn)/設(shè)備/覆蓋目錄中,則以下文件路徑均有效:
- 相對于設(shè)備定義文件:覆蓋/最小設(shè)備覆蓋.png
- 相對于包含資產(chǎn)目錄的目錄:資產(chǎn)/設(shè)備/覆蓋/最小設(shè)備覆蓋.png
此文由3D建模學(xué)習(xí)工作室整理翻譯,轉(zhuǎn)載請注明出處!
上一篇:Unity3D:模擬類 (mvrlink.com)文章來源:http://www.zghlxwxcb.cn/news/detail-499320.html
下一篇:Unity3D:擴展設(shè)備模擬器 (mvrlink.com)文章來源地址http://www.zghlxwxcb.cn/news/detail-499320.html
到了這里,關(guān)于Unity3D:添加設(shè)備的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!