Lớp công cụ
StudioDeviceSimulatorService
*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
CreateDeviceAsync
Tham Số
Lợi Nhuận
Mẫu mã
Ví dụ về Tạo Thiết Bị
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,
})GetDeviceInfoAsync
Tham Số
Lợi Nhuận
GetDeviceListAsync
GetOrientationAsync
Lợi Nhuận
GetScalingModeAsync
Lợi Nhuận
RemoveDeviceAsync
SetDeviceAsync
SetOrientationAsync
Tham Số
Lợi Nhuận
()
SetPixelDensityAsync
SetResolutionAsync
SetScalingModeAsync
Tham Số
Lợi Nhuận
()
StopSimulationAsync
StudioDeviceSimulatorService:StopSimulationAsync():()
Lợi Nhuận
()
UpdateDeviceAsync
Tham Số
Lợi Nhuận
()
Mẫu mã
Ví dụ Cập nhật Thiết bị
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
ConfigurationChanged
Mẫu mã
Ví dụ thay đổi cấu hình
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)