概要
代码示例
选中
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
endAPI 参考
属性
方法
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)