Class
StudioDeviceSimulatorService
NotCreatableServiceNotReplicated
Service allowing you to control Studio's Device Simulator.
Provides programmatic control over Studio's Device Simulator. Use this service to switch between device presets, override resolution and pixel density, control orientation and scaling, and manage custom device profiles from a plugin or from an external tool connected through the MCP server.
All methods are asynchronous and yield the calling coroutine. The service is available in Edit mode and Play Client. Methods that modify the active simulation state are blocked in PlayServer mode.
Limitations#
- All methods are asynchronous and yield the calling coroutine.
- Methods that modify the active simulation state (
SetDeviceAsync,StopSimulationAsync,SetOrientationAsync,SetResolutionAsync,SetPixelDensityAsync,SetScalingModeAsync) error in PlayServer mode. They work in Edit mode and Play Client. UpdateDeviceAsyncandRemoveDeviceAsyncerror when called on built-in presets.- Resolution, DPI, and scaling mode methods require an active device and error
when
GetDeviceAsync()returns "default". - Resolution and DPI overrides are session-level. They are not persisted and
are cleared on
SetDeviceAsync. - Built-in presets are immutable.
Methods 16#
| CreateDeviceAsync | Creates a custom device preset and returns its ID.PluginSecurity securityYields |
| GetDeviceAsync | Returns the ID of the currently active device, or "default" if none is
active.PluginSecurity securityYields |
| GetDeviceInfoAsync | Returns the configuration dictionary for the specified device.PluginSecurity securityYields |
| GetDeviceListAsync | Returns an array of all available device IDs.PluginSecurity securityYields |
| GetOrientationAsync | Returns the current simulated screen orientation.PluginSecurity securityYields |
| GetPixelDensityAsync | Returns the current simulated pixel density in DPI.PluginSecurity securityYields |
| GetResolutionAsync | Returns the current simulated viewport resolution.PluginSecurity securityYields |
| GetScalingModeAsync | Returns how the simulated resolution currently maps to the Studio viewport.PluginSecurity securityYields |
| RemoveDeviceAsync | Removes a custom device from the catalog.PluginSecurity securityYields |
| SetDeviceAsync | Activates the specified device or stops simulation if "default" is
passed.PluginSecurity securityYields |
| SetOrientationAsync | Sets the simulated screen orientation.PluginSecurity securityYields |
| SetPixelDensityAsync | Overrides the simulated pixel density in DPI for the current session.PluginSecurity securityYields |
| SetResolutionAsync | Overrides the simulated viewport resolution for the current session.PluginSecurity securityYields |
| SetScalingModeAsync | Sets how the simulated resolution maps to the Studio viewport.PluginSecurity securityYields |
| StopSimulationAsync | Stops the active device simulation.PluginSecurity securityYields |
| UpdateDeviceAsync | Updates the configuration of an existing custom device.PluginSecurity securityYields |
CreateDeviceAsync(config: Dictionary): string#
YieldsPluginSecurity security
Creates a custom device and returns its newly assigned ID. Custom devices are persisted to disk and appear in the Device Simulator UI.
Errors if any required field is missing or out of range.
| Name | Type | Default | Description |
|---|---|---|---|
config | Dictionary | A dictionary describing the new device. Required fields: Name
(string, 1-200 characters, cannot be "default"), Width (int,
1-7680 pixels), Height (int, 1-4320 pixels), PixelDensity (int,
72-10000 DPI). Optional fields: DeviceForm (DeviceForm,
default Phone), ResolutionScale (float, default 1.0, max 10.0),
PortraitKeyboardHeight (int, default 0), LandscapeKeyboardHeight
(int, default 0). |
Returns
string— string
GetDeviceAsync(): string#
YieldsPluginSecurity security
Returns the ID of the currently active device, or "default" if no device
is active.
Returns
string— string
GetDeviceInfoAsync(deviceId: string): Dictionary#
YieldsPluginSecurity security
Returns a DeviceConfiguration for the specified device without
activating it. Useful for inspecting presets before choosing one to switch
to.
The returned dictionary contains the following fields:
| Field | Type | Create/Update | Description |
|---|---|---|---|
DeviceId |
string | Read-only | Unique identifier assigned by the service. |
Name |
string | Required | Display name. 1 to 200 characters. Cannot be "default". |
Width |
number | Required | Screen width in pixels. Range: 1 to 7680. |
Height |
number | Required | Screen height in pixels. Range: 1 to 4320. |
PixelDensity |
number | Required | Pixel density in DPI. Range: 72 to 10000. |
DeviceForm |
Enum.DeviceForm |
Optional (default: Phone) | One of Phone, Tablet, Desktop, Console, VR. |
IsCustom |
boolean | Read-only | true if the device was user-created. |
ResolutionScale |
number | Optional (default: 1.0) | Resolution scaling factor. Must be greater than 0, max 10.0. |
PortraitKeyboardHeight |
number | Optional (default: 0) | Virtual keyboard height in portrait mode. |
LandscapeKeyboardHeight |
number | Optional (default: 0) | Virtual keyboard height in landscape mode. |
| Name | Type | Default | Description |
|---|---|---|---|
deviceId | string | The unique identifier of the device to query. Must be a valid ID from
GetDeviceListAsync(); cannot be "default". |
Returns
Dictionary— A dictionary containing the device configuration and passed toCreateDeviceAsyncandUpdateDeviceAsync.
GetDeviceListAsync(): Array#
YieldsPluginSecurity security
Returns an array of device IDs for all available presets, including built-in and custom devices.
Returns
Array— An array of device IDs.
GetOrientationAsync(): ScreenOrientation#
YieldsPluginSecurity security
Returns the current simulated orientation.
Returns
ScreenOrientation— ScreenOrientation
GetPixelDensityAsync(): float#
YieldsPluginSecurity security
Returns the current simulated pixel density.
Returns
float— number
GetResolutionAsync(): Vector2#
YieldsPluginSecurity security
Returns the current simulated resolution.
Returns
Vector2— Vector2
GetScalingModeAsync(): DeviceSimulatorScalingMode#
YieldsPluginSecurity security
Returns the current DeviceSimulatorScalingMode for how the
simulated resolution maps to the Studio viewport. See
SetScalingModeAsync()
for the available modes.
Requires an active device; errors when GetDeviceAsync() returns
"default".
Returns
DeviceSimulatorScalingMode— The currentDeviceSimulatorScalingMode.
RemoveDeviceAsync(deviceId: string): ()#
YieldsPluginSecurity security
Removes a custom device.
Errors if the target is a built-in preset.
| Name | Type | Default | Description |
|---|---|---|---|
deviceId | string | The unique identifier of the custom device to remove. |
Returns
()
SetDeviceAsync(deviceId: string): ()#
YieldsPluginSecurity security
Activates the specified device. Passing "default" stops simulation and
is equivalent to calling StopSimulationAsync.
Errors in PlayServer mode. Errors if the device ID does not exist.
| Name | Type | Default | Description |
|---|---|---|---|
deviceId | string | The unique identifier of the device to activate, or "default" to
stop simulation. |
Returns
()
SetOrientationAsync(orientation: ScreenOrientation): ()#
YieldsPluginSecurity security
Sets or gets the simulated screen orientation. Accepts Portrait, LandscapeLeft, or LandscapeRight. Other values will error.
Errors in PlayServer mode.
| Name | Type | Default | Description |
|---|---|---|---|
orientation | ScreenOrientation | The target screen orientation. Accepted values are
ScreenOrientation.Portrait,
ScreenOrientation.LandscapeLeft, or
ScreenOrientation.LandscapeRight. |
Returns
()
SetPixelDensityAsync(density: float): ()#
YieldsPluginSecurity security
Overrides or returns the simulated pixel density in DPI. Session-level; cleared on device switch.
This method requires an active device. SetPixelDensityAsync also errors
in PlayServer mode.
| Name | Type | Default | Description |
|---|---|---|---|
density | float | The pixel density override in DPI. Must be between 72 and 10000. |
Returns
()
SetResolutionAsync(width: int, height: int): ()#
YieldsPluginSecurity security
Overrides the simulated viewport resolution or returns the current resolution as a Vector2. Overrides are session-level and cleared when you switch devices.
Coordinates are in landscape space: the first parameter maps to the horizontal axis in landscape, the second to the vertical axis. In portrait, axes are swapped automatically.
Both methods require an active device. They error if GetDeviceAsync()
returns "default". SetResolutionAsync also errors in PlayServer mode.
| Name | Type | Default | Description |
|---|---|---|---|
width | int | The viewport width in pixels (horizontal axis in landscape orientation). Range: 1 to 7680. | |
height | int | The viewport height in pixels (vertical axis in landscape orientation). Range: 1 to 4320. |
Returns
()
SetScalingModeAsync(mode: DeviceSimulatorScalingMode): ()#
YieldsPluginSecurity security
Controls how the simulated resolution maps to the Studio viewport.
ScaleToPhysicalSizescales the viewport to approximate physical device size.ActualResolutionrenders at exact pixel resolution.FitToWindowscales to fill the viewport.
Both methods require an active device. SetScalingModeAsync also errors
in PlayServer mode.
| Name | Type | Default | Description |
|---|---|---|---|
mode | DeviceSimulatorScalingMode | The scaling mode to apply. One of
DeviceSimulatorScalingMode.ScaleToPhysicalSize,
DeviceSimulatorScalingMode.ActualResolution, or
DeviceSimulatorScalingMode.FitToWindow. |
Returns
()
StopSimulationAsync(): ()#
YieldsPluginSecurity security
Stops the active simulation. Prefer this over SetDeviceAsync("default")
for clarity.
Errors in PlayServer mode.
Returns
()
UpdateDeviceAsync(deviceId: string, config: Dictionary): ()#
YieldsPluginSecurity security
Updates a custom device's configuration.
Errors if the target is a built-in preset.
| Name | Type | Default | Description |
|---|---|---|---|
deviceId | string | The unique identifier of the custom device to update. | |
config | Dictionary | A dictionary of device fields to apply. Uses patch semantics: omitted
optional fields retain their current values. Same schema as
CreateDeviceAsync(). |
Returns
()