概要
方法
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)