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" -- 創建設備時返回的 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)