Studio Device Simulator Service
摘要
方法
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 参考
方法
Create Device Async
参数
返回
代码示例
创建设备示例
local Simulator = game:GetService("StudioDeviceSimulatorService")
local id = Simulator:CreateDeviceAsync({
Name = "我的自定义平板电脑",
Width = 2560,
Height = 1600,
PixelDensity = 300,
DeviceForm = Enum.DeviceForm.Tablet,
})
print(id)Get Device Info Async
参数
Get Device List Async
Get Orientation Async
Get Scaling Mode Async
Remove Device Async
Set Orientation Async
参数
返回
()
Set Pixel Density Async
Set Resolution Async
Set Scaling Mode Async
返回
()
Stop Simulation Async
Studio Device Simulator Service: Stop Simulation Async():()
返回
()
Update Device Async
参数
返回
()
代码示例
更新设备示例
local Simulator = game:GetService("StudioDeviceSimulatorService")
local id = "CUSTOM_DEVICE_ID" -- CreateDeviceAsync 返回的 id
Simulator:UpdateDeviceAsync(id, {
Name = "我的自定义平板电脑",
Width = 2732,
Height = 2048,
PixelDensity = 264,
DeviceForm = Enum.DeviceForm.Tablet,
})活动
Configuration Changed
代码示例
配置更改示例
local Simulator = game:GetService("StudioDeviceSimulatorService")
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)