Studio Device Simulator Service
*Nội dung này được dịch bằng AI (Beta) và có thể có lỗi. Để xem trang này bằng tiếng Anh, hãy nhấp vào đây.
Tóm tắt
Phương Pháp
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):() |
Sự Kiện
Tài Liệu Tham Khảo API
Phương Pháp
Create Device Async
Tham Số
Lợi Nhuận
Mẫu mã
Ví dụ về Tạo Thiết Bị
local Simulator = game:GetService("StudioDeviceSimulatorService")
local id = Simulator:CreateDeviceAsync({
Name = "Máy tính bảng tùy chỉnh của tôi",
Width = 2560,
Height = 1600,
PixelDensity = 300,
DeviceForm = Enum.DeviceForm.Tablet,
})
print(id)Get Device Info Async
Tham Số
Lợi Nhuận
Get Device List Async
Get Orientation Async
Lợi Nhuận
Get Scaling Mode Async
Lợi Nhuận
Remove Device Async
Set Device Async
Set Orientation Async
Tham Số
Lợi Nhuận
()
Set Pixel Density Async
Set Resolution Async
Set Scaling Mode Async
Tham Số
Lợi Nhuận
()
Stop Simulation Async
Studio Device Simulator Service: Stop Simulation Async():()
Lợi Nhuận
()
Update Device Async
Tham Số
Lợi Nhuận
()
Mẫu mã
Ví dụ Cập nhật Thiết bị
local Simulator = game:GetService("StudioDeviceSimulatorService")
local id = "CUSTOM_DEVICE_ID" -- ID được trả về bởi CreateDeviceAsync
Simulator:UpdateDeviceAsync(id, {
Name = "Máy tính bảng tùy chỉnh của tôi",
Width = 2732,
Height = 2048,
PixelDensity = 264,
DeviceForm = Enum.DeviceForm.Tablet,
})Sự Kiện
Configuration Changed
Mẫu mã
Ví dụ thay đổi cấu hình
local Simulator = game:GetService("StudioDeviceSimulatorService")
Simulator.ConfigurationChanged:Connect(function()
local deviceId = Simulator:GetDeviceAsync()
if deviceId ~= "default" then
local res = Simulator:GetResolutionAsync()
print(string.format("Đang hoạt động: %s @ %dx%d", deviceId, res.X, res.Y))
end
end)