# StudioDeviceSimulatorService

Roblox Engine API class from Roblox Studio 0.744.0.7441077 (version-7aaa6838d36c4448).

- Inherits from, nearest first: [Instance](https://rapi.sleaze.dev/classes/Instance.md), [Object](https://rapi.sleaze.dev/classes/Object.md)
- Tags: Not creatable, Not replicated, Service
- Memory category: Instances
- HTML page: https://rapi.sleaze.dev/classes/StudioDeviceSimulatorService/
- Roblox documentation: https://create.roblox.com/docs/reference/engine/classes/StudioDeviceSimulatorService

Service allowing you to control Studio's Device Simulator.

## Methods

### CreateDeviceAsync

```luau
StudioDeviceSimulatorService:CreateDeviceAsync(config: { [string]: any }): string
```

- Tags: Yields, Plugin security

Creates a custom device preset and returns its ID.

Parameters:

- `config`: A dictionary describing the new device. Required fields: [`Name`](https://rapi.sleaze.dev/classes/Instance.md) (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

### GetDeviceAsync

```luau
StudioDeviceSimulatorService:GetDeviceAsync(): string
```

- Tags: Yields, Plugin security

Returns the ID of the currently active device, or `"default"` if none is active.

Returns: string

### GetDeviceInfoAsync

```luau
StudioDeviceSimulatorService:GetDeviceInfoAsync(deviceId: string): { [string]: any }
```

- Tags: Yields, Plugin security

Returns the configuration dictionary for the specified device.

Parameters:

- `deviceId`: The unique identifier of the device to query. Must be a valid ID from [`GetDeviceListAsync()`](https://rapi.sleaze.dev/classes/StudioDeviceSimulatorService.md); cannot be `"default"`.

Returns: A dictionary containing the device configuration and passed to [`CreateDeviceAsync`](https://rapi.sleaze.dev/classes/StudioDeviceSimulatorService.md) and [`UpdateDeviceAsync`](https://rapi.sleaze.dev/classes/StudioDeviceSimulatorService.md).

### GetDeviceListAsync

```luau
StudioDeviceSimulatorService:GetDeviceListAsync(): { any }
```

- Tags: Yields, Plugin security

Returns an array of all available device IDs.

Returns: An array of device IDs.

### GetOrientationAsync

```luau
StudioDeviceSimulatorService:GetOrientationAsync(): Enum.ScreenOrientation
```

- Tags: Yields, Plugin security

Returns the current simulated screen orientation.

Returns: ScreenOrientation

### GetPixelDensityAsync

```luau
StudioDeviceSimulatorService:GetPixelDensityAsync(): number
```

- Tags: Yields, Plugin security

Returns the current simulated pixel density in DPI.

Returns: number

### GetResolutionAsync

```luau
StudioDeviceSimulatorService:GetResolutionAsync(): Vector2
```

- Tags: Yields, Plugin security

Returns the current simulated viewport resolution.

Returns: Vector2

### GetScalingModeAsync

```luau
StudioDeviceSimulatorService:GetScalingModeAsync(): Enum.DeviceSimulatorScalingMode
```

- Tags: Yields, Plugin security

Returns how the simulated resolution currently maps to the Studio viewport.

Returns: The current `DeviceSimulatorScalingMode`.

### RemoveDeviceAsync

```luau
StudioDeviceSimulatorService:RemoveDeviceAsync(deviceId: string)
```

- Tags: Yields, Plugin security

Removes a custom device from the catalog.

Parameters:

- `deviceId`: The unique identifier of the custom device to remove.

### SetDeviceAsync

```luau
StudioDeviceSimulatorService:SetDeviceAsync(deviceId: string)
```

- Tags: Yields, Plugin security

Activates the specified device or stops simulation if `"default"` is passed.

Parameters:

- `deviceId`: The unique identifier of the device to activate, or `"default"` to stop simulation.

### SetOrientationAsync

```luau
StudioDeviceSimulatorService:SetOrientationAsync(orientation: Enum.ScreenOrientation)
```

- Tags: Yields, Plugin security

Sets the simulated screen orientation.

Parameters:

- `orientation`: The target screen orientation. Accepted values are `ScreenOrientation.Portrait`, `ScreenOrientation.LandscapeLeft`, or `ScreenOrientation.LandscapeRight`.

### SetPixelDensityAsync

```luau
StudioDeviceSimulatorService:SetPixelDensityAsync(density: number)
```

- Tags: Yields, Plugin security

Overrides the simulated pixel density in DPI for the current session.

Parameters:

- `density`: The pixel density override in DPI. Must be between 72 and 10000.

### SetResolutionAsync

```luau
StudioDeviceSimulatorService:SetResolutionAsync(width: number, height: number)
```

- Tags: Yields, Plugin security

Overrides the simulated viewport resolution for the current session.

Parameters:

- `width`: The viewport width in pixels (horizontal axis in landscape orientation). Range: 1 to 7680.
- `height`: The viewport height in pixels (vertical axis in landscape orientation). Range: 1 to 4320.

### SetScalingModeAsync

```luau
StudioDeviceSimulatorService:SetScalingModeAsync(mode: Enum.DeviceSimulatorScalingMode)
```

- Tags: Yields, Plugin security

Sets how the simulated resolution maps to the Studio viewport.

Parameters:

- `mode`: The scaling mode to apply. One of `DeviceSimulatorScalingMode.ScaleToPhysicalSize`, `DeviceSimulatorScalingMode.ActualResolution`, or `DeviceSimulatorScalingMode.FitToWindow`.

### StopSimulationAsync

```luau
StudioDeviceSimulatorService:StopSimulationAsync()
```

- Tags: Yields, Plugin security

Stops the active device simulation.

### UpdateDeviceAsync

```luau
StudioDeviceSimulatorService:UpdateDeviceAsync(deviceId: string, config: { [string]: any })
```

- Tags: Yields, Plugin security

Updates the configuration of an existing custom device.

Parameters:

- `deviceId`: The unique identifier of the custom device to update.
- `config`: A dictionary of device fields to apply. Uses patch semantics: omitted optional fields retain their current values. Same schema as [`CreateDeviceAsync()`](https://rapi.sleaze.dev/classes/StudioDeviceSimulatorService.md).

## Events

### ConfigurationChanged

```luau
StudioDeviceSimulatorService.ConfigurationChanged: RBXScriptSignal<()>
```

- Tags: Plugin security

Fires when the active simulation state changes.

## Inherited members

- From [Instance](https://rapi.sleaze.dev/classes/Instance.md): `Archivable`, `archivable`, `Attributes`, `AttributesReplicate`, `AttributesSerialize`, `HistoryId`, `Name`, `Parent`, `PredictionMode`, `PropertyStatusStudio`, `RobloxLocked`, `SerializedOverrides`, `SourceAssetId`, `Tags`, `UniqueId`, `numExpectedDirectChildren`, `DataCost`, `Capabilities`, `DefinesCapabilities`, `IsInSandbox`, `Sandboxed`, `AddTag`, `ClearAllChildren`, `Clone`, `Destroy`, `FindFirstAncestor`, `FindFirstAncestorOfClass`, `FindFirstAncestorWhichIsA`, `FindFirstChild`, `FindFirstChildOfClass`, `FindFirstChildWhichIsA`, `FindFirstDescendant`, `GetActor`, `GetAttribute`, `GetAttributeChangedSignal`, `GetAttributes`, `GetChildren`, `GetDebugId`, `GetDescendants`, `GetFullName`, `GetStyled`, `GetStyledPropertyChangedSignal`, `GetTags`, `HasTag`, `IsAncestorOf`, `IsDescendantOf`, `IsPropertyModified`, `QueryDescendants`, `RemoveTag`, `ResetPropertyToDefault`, `SetAttribute`, `WaitForChild`, `Remove`, `children`, `clone`, `destroy`, `findFirstChild`, `getChildren`, `isDescendantOf`, `remove`, `AncestryChanged`, `AttributeChanged`, `ChildAdded`, `ChildRemoved`, `DescendantAdded`, `DescendantRemoving`, `Destroying`, `StyledPropertiesChanged`, `childAdded`
- From [Object](https://rapi.sleaze.dev/classes/Object.md): `ClassName`, `className`, `GetPropertyChangedSignal`, `IsA`, `isA`, `Changed`
