Engine Class
Selection
*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่
สรุป
คุณสมบัติ
วิธีการ
Add(instancesToAdd: Instances):() |
Get():Instances |
Remove(instancesToRemove: Instances):() |
Set(selection: Instances):() |
เหตุการณ์
ตัวอย่างโค้ด
การเลือก
local Selection = game:GetService("Selection")
for _, object in pairs(Selection:Get()) do
if object:IsA("BasePart") then
object.CFrame = object.CFrame * CFrame.Angles(0, math.pi / 2, 0)
end
endเอกสารอ้างอิงเกี่ยวกับ API
คุณสมบัติ
วิธีการ
Add
Selection:Add(instancesToAdd:Instances):()
พารามิเตอร์
instancesToAdd:Instances |
ส่งค่ากลับ
()
Get
Selection:Get():Instances
ส่งค่ากลับ
Instances
ตัวอย่างโค้ด
การเลือก
local Selection = game:GetService("Selection")
for _, object in pairs(Selection:Get()) do
if object:IsA("BasePart") then
object.CFrame = object.CFrame * CFrame.Angles(0, math.pi / 2, 0)
end
endการเปลี่ยนแปลงการเลือก
local selection = game:GetService("Selection")
selection.SelectionChanged:Connect(function()
print("การเลือกมี " .. #selection:Get() .. " รายการ.")
end)Remove
Selection:Remove(instancesToRemove:Instances):()
พารามิเตอร์
instancesToRemove:Instances |
ส่งค่ากลับ
()
Set
Selection:Set(selection:Instances):()
พารามิเตอร์
selection:Instances |
ส่งค่ากลับ
()
ตัวอย่างโค้ด
การเลือกชุด
local Selection = game:GetService("Selection")
local newSelection = {}
for _, object in pairs(workspace:GetDescendants()) do
if object:IsA("BasePart") and object.BrickColor == BrickColor.new("Bright red") then
table.insert(newSelection, object)
end
end
Selection:Set(newSelection)เหตุการณ์
SelectionChanged
ตัวอย่างโค้ด
การเปลี่ยนแปลงการเลือก
local selection = game:GetService("Selection")
selection.SelectionChanged:Connect(function()
print("การเลือกมี " .. #selection:Get() .. " รายการ.")
end)