Device Simulator (デバイスシミュレーター)に新しいデバイスを追加するには、デバイス定義とデバイスオーバーレイを作成します。
デバイス定義は、Unity プロジェクトにある、.device
拡張子を持つテキストファイルです。このファイルには、デバイスのプロパティを記述した JSON が含まれています。
デバイスオーバーレイは、デバイス画面の境界線、ノッチ、パンチアウト、および画面の矩形領域へのその他の追加を含む画像です。任意でデバイス定義と一緒に使用すると、ハードウェア要素がデバイス画面をどのように妨げるかを視覚化し、その結果、タッチ入力がいつ失敗するかを判断することができます。
デバイス定義は、デバイスを表す JSON ファイルです。必須のプロパティといくつかの任意のプロパティの両方があります。デバイス定義ファイルにエラーがある場合、ファイルを選択すると Inspector にエラーが表示されます。
プロパティ | 必須 | 説明 |
---|---|---|
friendlyName | はい | このデバイスの UI に表示する名前です。 |
version | はい | デバイス定義ファイルのバージョンを示す。現在、バージョンは 1 です。 |
screens | はい | デバイスをシミュレートするための画面 (screen) をそれぞれ記述したオブジェクトのリスト。これには少なくとも 1 つの screen が含まれていなければなりません。各スクリーンオブジェクトのスキーマについては、screen を参照してください。 |
systemInfo | はい | デバイスの能力を記述したオブジェクト。このオブジェクトの値は、SystemInfo にマップされます。systemInfo オブジェクトのスキーマについては、systemInfo を参照してください。 |
プロパティ | 必須 | 説明 |
---|---|---|
width | はい | 画面の幅 (ピクセル単位)。 |
height | はい | 画面の高さ (ピクセル単位)。 |
navigationBarHeight | いいえ | 全画面でないときに、一部のデバイスで表示される画面上の Android ナビゲーションバーの高さ (ピクセル単位)。 |
dpi | はい | 画面の dpi。 |
orientations | いいえ | 画面がシミュレートできる方向をそれぞれ記述したオブジェクトのリスト。このプロパティに値を設定しない場合、画面はすべての方向をサポートします。各 orientation オブジェクトのスキーマについては、orientation を参照してください。 |
presentation | いいえ | デバイスオーバーレイを記述するオブジェクト。このオブジェクトのスキーマについては、プレゼンテーション を参照してください。presentation |
Properties | 必須 | 説明 |
---|---|---|
orientation | はい | 画面の向き。このプロパティの値は、ScreenOrientation enum に対応する数値です。 |
safeArea | いいえ | 画面のセーフエリアを決定する Rect。このプロパティに値を設定しないと、シミュレーターは画面全体がセーフであると見なします。 |
cutouts | いいえ | コンテンツを表示できない画面のエリアを指定する Rect のリスト。 |
プロパティ | 必須 | 説明 |
---|---|---|
overlayPath | いいえ | デバイス定義ファイルから、デバイスのオーバーレイとして使用する画像への相対パス。 |
borderSize | いいえ | オーバーレイから画面の開始位置までの距離 (ピクセル単位)。 |
このオブジェクトのプロパティは、デバイスの機能とシステム情報を記述します。システム情報を記述するため、その多くは SystemInfo のプロパティに対応します。
プロパティ | 必須 | 説明 |
---|---|---|
deviceModel | いいえ | Device.SystemInfo.deviceModel を参照。 |
deviceType | いいえ | Device.SystemInfo.deviceType を参照。 |
operatingSystem | はい | Device.SystemInfo.operatingSystem を参照。 |
operatingSystemFamily | いいえ | Device.SystemInfo.operatingSystemFamily を参照。 |
processorCount | いいえ | Device.SystemInfo.processorCount を参照。 |
processorFrequency | いいえ | Device.SystemInfo.processorFrequency を参照。 |
processorType | いいえ | Device.SystemInfo.processorType を参照。 |
supportsAccelerometer | いいえ | Device.SystemInfo.supportsAccelerometer を参照。 |
supportsAudio | いいえ | Device.SystemInfo.supportsAudio を参照。 |
supportsGyroscope | いいえ | Device.SystemInfo.supportsGyroscope を参照。 |
supportsLocationService | いいえ | Device.SystemInfo.supportsLocationService を参照。 |
supportsVibration | いいえ | Device.SystemInfo.supportsVibration を参照。 |
systemMemorySize | いいえ | Device.SystemInfo.systemMemorySize を参照。 |
unsupportedIdentifier | いいえ | Device.SystemInfo.unsupportedIdentifier を。 |
graphicsDependentData | いいえ | デバイスがサポートするグラフィックス API を記述したオブジェクトのリストです。各オブジェクトのスキーマについては、graphicsDependentData を参照してください。 |
オブジェクトのプロパティは、デバイスがサポートするグラフィックス API を記述します。
以下のデバイス定義には、すべての必須プロパティが含まれ、任意のプロパティは含まれていません。これは、最低限のデバイス定義です。
ノート: このデバイスの定義は、orientation (向き) のデータを提供しません。そのため、シミュレーターはデバイスがすべての方向をサポートし、セーフエリアが画面全体を覆っていると仮定します。
{
"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
}
]
}
}
デバイスオーバーレイは、デバイス画面の境界線と、ノッチ、パンチアウト、および画面の矩形領域へのその他の追加機能を含む画像です。任意でデバイス定義と一緒に使用すると、ハードウェア要素がデバイス画面をどのように妨げるかを視覚化し、その結果、タッチ入力がいつ失敗するかを判断することができます。
デバイスシミュレーターは、透明なピクセルはタップできる画面領域、それ以外の色の不透明なピクセルはハードウェアが妨げる領域と解釈します。テクスチャ自体はどんな形でも構いません。
以下の例では、2 つの iPhone モデルのデバイスオーバーレイを示しています。
ノート: デバイスオーバーレイを使用するときの見え方を模倣するため、これらの例では画面のタブを作成する領域に Unity のデフォルトのスカイボックスを表示しています。実際のデバイスオーバーレイでは、これらのピクセルは透明です。
Apple iPhone 8 オーバーレイ | Apple iPhone XS オーバーレイ |
---|---|
![]() |
![]() |
デバイスオーバーレイテクスチャを作成した後に、それをデバイス定義と一緒に使用するには、まずデバイスオーバーレイテクスチャファイルをプロジェクトにインポートする必要があります。
ノート: デバイスシミュレーターがデバイスオーバーレイテクスチャをロードするとき、Read/Write を有効にしようとします。これができない場合、デバイスシミュレーターはテクスチャを表示しますが、テクスチャを入力のマスクに使用することはできません。つまり、デバイスオーバーレイがマスクすべき画面のノッチやその他の領域をクリックすると、デバイスシミュレーターは入力を検出します。このようなことが起こらないようにするには、デバイスオーバーレイテクスチャをインポートするときに、Texture Import Settings ウィンドウで Read/Write を有効にします。
デバイスオーバーレイテクスチャがプロジェクトにある場合、デバイス定義ファイルを開き、デバイスがサポートする画面を定義するオブジェクトに、presentation プロパティを加えてください。ここで、画像ファイルへのパス (overlayPath
) と border のサイズ (borderSize
) を設定します。この方法の例として、以下のデバイス定義ファイルを参照してください。
{
"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 プロジェクト内の Assets または Packages ディレクトリを含むディレクトリからの相対パスです。例えば、デバイス定義ファイルが Assets/Devices ディレクトリにあり、デバイス オーバーレイ ファイルが Assets/Devices/Overlays ディレクトリにある場合、以下のファイルパスは両方とも有効です。
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.