Engine Class
StudioDeviceSimulatorService
*เนื้อหานี้แปลโดยใช้ 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
วิธีการ
CreateDeviceAsync
พารามิเตอร์
ส่งค่ากลับ
ตัวอย่างโค้ด
ตัวอย่างการสร้างอุปกรณ์
local id = Simulator:CreateDeviceAsync({
Name = "แท็บเล็ตคัสตอมของฉัน",
Width = 2560,
Height = 1600,
PixelDensity = 300,
DeviceForm = Enum.DeviceForm.Tablet,
})GetDeviceInfoAsync
พารามิเตอร์
ส่งค่ากลับ
GetDeviceListAsync
GetOrientationAsync
ส่งค่ากลับ
GetScalingModeAsync
ส่งค่ากลับ
RemoveDeviceAsync
SetDeviceAsync
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)