Selection

사용되지 않는 항목 표시

*이 콘텐츠는 AI(베타)를 사용해 번역되었으며, 오류가 있을 수 있습니다. 이 페이지를 영어로 보려면 여기를 클릭하세요.

만들 수 없음
서비스

선택 서비스는 Roblox Studio에서 선택된 Instances를 제어합니다.

이 서비스는 현재 선택에 액세스하고 조작할 수 있게 하기 때문에 Plugins 를 개발할 때 특히 유용합니다.

현재 선택된 InstancesSelection:Get()Selection:Set() 함수를 사용하여 얻고 설정할 수 있습니다.현재 선택이 변경될 때마다 Selection.SelectionChanged 이벤트가 발생합니다.

자세한 내용은 SelectionPlugins 사용에 대해 참조하십시오. Plugin .

선택은 명령줄에서도 자주 사용되어 숨겨진 속성을 설정하거나 선택한 Instances에 대한 함수를 실행합니다.

이 클래스는 Roblox Studio에만 적용되며 게임에는 적용할 수 없습니다.

코드 샘플

The following code sample, when used in a plugin or the command bar, will rotate currently selected BaseParts.

Selection

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

요약

메서드

  • Add(instancesToAdd : Instances):()
    플러그인 보안
  • Get():Instances
    플러그인 보안

    Roblox Studio에서 현재 선택된 배열 Instances를 반환합니다.

  • Remove(instancesToRemove : Instances):()
    플러그인 보안
  • Set(selection : Instances):()
    플러그인 보안

    Roblox Studio에서 현재 선택된 개체를 지정된 배열에서 Instances로 설정합니다.

속성

SelectionThickness

읽기 전용
복제되지 않음
병렬 읽기

메서드

Add

()
플러그인 보안

매개 변수

instancesToAdd: Instances
기본값: ""

반환

()

Get

Instances
플러그인 보안

Roblox Studio에서 현재 선택된 배열 Instances를 반환합니다.

Instances가 선택되지 않으면 반환된 배열이 비어 있습니다.이 함수는 Selection.SelectionChanged 이벤트와 함께 사용하여 변경될 때마다 선택을 가져올 수 있습니다.

참고, 이 함수는 Plugins 또는 명령줄에서만 사용할 수 있습니다.

현재 선택을 변경하려면 Selection:Set()를 참조하십시오.


반환

Instances

현재 선택된 배열 Instances .

코드 샘플

The following code sample, when used in a plugin or the command bar, will rotate currently selected BaseParts.

Selection

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

This example prints the number of selected items whenever SelectionChanged is fired:

Selection.SelectionChanged

local selection = game:GetService("Selection")
selection.SelectionChanged:Connect(function()
print("Selection contains " .. #selection:Get() .. " items.")
end)

Remove

()
플러그인 보안

매개 변수

instancesToRemove: Instances
기본값: ""

반환

()

Set

()
플러그인 보안

Roblox Studio에서 현재 선택된 개체를 지정된 배열에서 Instances로 설정합니다.

이 함수를 호출하면 새 선택 집합이 이전 선택 집합과 동일하지 않은 경우 Selection.SelectionChanged 이벤트가 발생하지만, 새 선택 집합이 이전 선택 집합과 동일한 경우에는 발생하지 않습니다.

이 함수는 기존 선택을 재정의하지만, Selection:Get()Instance 를 사용하여 기존 선택에 다음과 같이 추가할 수 있습니다.


local selected = Selection:Get()
table.insert(selected, object)
Selection:Set(selected)

매개 변수

selection: Instances

현재 선택을 설정할 Instances 배열.

기본값: ""

반환

()

코드 샘플

This code sample will select every BasePart in the workspace that is Bright red.

Selection Set

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

Roblox Studio에서 선택한 Instances가 변경될 때 발생하는 화재.

이 이벤트는 새로운 선택을 제공하지 않습니다. 개발자는 Selection:Get() 함수를 사용하여 현재 선택을 얻어야 합니다.

이 이벤트는 플러그인과 명령 모음 외부에서 사용할 수 있지만, Roblox Studio에서의 선택에만 적용되므로 Studio 외부에는 기능이 없습니다.

선택을 변경하려면 Selection:Set() 함수를 사용하십시오.


코드 샘플

This example prints the number of selected items whenever SelectionChanged is fired:

Selection.SelectionChanged

local selection = game:GetService("Selection")
selection.SelectionChanged:Connect(function()
print("Selection contains " .. #selection:Get() .. " items.")
end)