概要
方法
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):() |
API 参考
方法
CreateDeviceAsync
参数
返回
代码示例
创建设备示例
local id = Simulator:CreateDeviceAsync({
Name = "我的自定义平板电脑",
Width = 2560,
Height = 1600,
PixelDensity = 300,
DeviceForm = Enum.DeviceForm.Tablet,
})GetDeviceInfoAsync
参数
GetDeviceListAsync
GetOrientationAsync
GetScalingModeAsync
RemoveDeviceAsync
SetOrientationAsync
参数
返回
()
SetPixelDensityAsync
SetResolutionAsync
SetScalingModeAsync
返回
()
StopSimulationAsync
StudioDeviceSimulatorService:StopSimulationAsync():()
返回
()
UpdateDeviceAsync
参数
返回
()
代码示例
更新设备示例
Simulator:UpdateDeviceAsync(id, {
Name = "我的自定义平板",
Width = 2732,
Height = 2048,
PixelDensity = 264,
DeviceForm = Enum.DeviceForm.Tablet,
})活动
ConfigurationChanged
代码示例
配置更改示例
Simulator.ConfigurationChanged:Connect(function()
local deviceId = Simulator:GetDeviceAsync()
if deviceId ~= "default" then
local res = Simulator:GetResolutionAsync()
print(string.format("活动: %s @ %dx%d", deviceId, res.X, res.Y))
end
end)