Classe do mecanismo
StudioDeviceSimulatorService
*Este conteúdo é traduzido por IA (Beta) e pode conter erros. Para ver a página em inglês, clique aqui.
Resumo
Métodos
CreateDeviceAsync(config: Dictionary):string |
GetDeviceInfoAsync(deviceId: string):Dictionary |
RemoveDeviceAsync(deviceId: string):() |
SetDeviceAsync(deviceId: string):() |
SetOrientationAsync(orientation: Enum.ScreenOrientation):() |
SetPixelDensityAsync(density: number):() |
SetResolutionAsync(width: number,height: number):() |
StopSimulationAsync():() |
UpdateDeviceAsync(deviceId: string,config: Dictionary):() |
Eventos
Referência API
Métodos
CreateDeviceAsync
Parâmetros
Devolução
Amostras de código
Exemplo de Criar Dispositivo
local id = Simulator:CreateDeviceAsync({
Name = "Meu Tablet Personalizado",
Width = 2560,
Height = 1600,
PixelDensity = 300,
DeviceForm = Enum.DeviceForm.Tablet,
})GetDeviceInfoAsync
Parâmetros
Devolução
GetDeviceListAsync
GetOrientationAsync
Devolução
GetScalingModeAsync
Devolução
RemoveDeviceAsync
SetDeviceAsync
SetOrientationAsync
Parâmetros
Devolução
()
SetPixelDensityAsync
SetResolutionAsync
SetScalingModeAsync
Parâmetros
Devolução
()
StopSimulationAsync
StudioDeviceSimulatorService:StopSimulationAsync():()
Devolução
()
UpdateDeviceAsync
Parâmetros
Devolução
()
Amostras de código
Exemplo de Atualização de Dispositivo
Simulator:UpdateDeviceAsync(id, {
Name = "Meu Tablet Personalizado",
Width = 2732,
Height = 2048,
PixelDensity = 264,
DeviceForm = Enum.DeviceForm.Tablet,
})Eventos
ConfigurationChanged
Amostras de código
Exemplo de alteração de configuração
Simulator.ConfigurationChanged:Connect(function()
local deviceId = Simulator:GetDeviceAsync()
if deviceId ~= "default" then
local res = Simulator:GetResolutionAsync()
print(string.format("Ativo: %s @ %dx%d", deviceId, res.X, res.Y))
end
end)