Studio Device Simulator Service
*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่
ข้อมูลสรุป
วิธีการ
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 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
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)