ChangeHistoryService

사용되지 않는 항목 표시

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

만들 수 없음
서비스

플러그인 개발자 레코딩을 통해 플러그인이 경험에 적용하는 변경을 취소하고 다시 수행하도록 Studio에 알리기 위해 ChangeHistoryService 사용해야 합니다.변경하기 전에 플러그인은 ChangeHistoryService:TryBeginRecording() 을 호출하여 할당된 식별자를 기억하고, 변경 사항을 적용한 후에는 플러그인이 ChangeHistoryService:FinishRecording() 를 호출하여 녹음을 완료합니다.

플러그인은 또한 ChangeHistoryService:Undo() 또는 ChangeHistoryService:Redo()를 통해 실행 취소 또는 다시 실행을 프로그래밍 방식으로 호출할 수 있습니다.

ChangeHistoryService 는 런타임에 활성화되지 않으므로 실행 중인 경험에서 메서드를 호출하면 효과가 없습니다.

요약

메서드

  • FinishRecording(identifier : string,operation : Enum.FinishRecordingOperation,finalOptions : Dictionary?):()
    플러그인 보안

    식별된 레코딩이 완료되었으며 최종 작업을 수행하여 레코딩을 완료하도록 Studio에 통신합니다.

  • 플러그인 보안

    되돌릴 수 있는 작업이 있는지 여부를 반환하고, 있으면 마지막 작업을 반환합니다.

  • 플러그인 보안

    취소할 수 있는 작업이 있는지 여부를 반환하고, 있으면 마지막 작업을 반환합니다.

  • 플러그인 보안
  • Redo():()
    플러그인 보안

    취소된 마지막 작업을 실행합니다.

  • 플러그인 보안

    기록을 지우고 모든 실행 취소/다시 실행 경로가 제거됩니다.

  • SetEnabled(state : boolean):()
    플러그인 보안

    변경 내역 서비스를 활성화할지 여부를 설정합니다.

  • SetWaypoint(name : string):()
    플러그인 보안

    실행 취소나 다시 실행할 수 있는 새로운 웨이포인트를 설정합니다.

  • TryBeginRecording(name : string,displayName : string?):string?
    플러그인 보안

    데이터 모델에 적용된 변경 사항을 기록으로 추적하기 시작합니다.

  • Undo():()
    플러그인 보안

    방향점이 있는 마지막 행동을 취소합니다.

이벤트

속성

메서드

FinishRecording

()
플러그인 보안

매개 변수

identifier: string

이전 호출에서 검색된 레코드를 TryBeginRecording() 로 식별합니다.작업이 Enum.ChangeHistoryService.FinishRecordingOperation.Cancel 이면 이 값은 무시되고 레코딩은 컨텍스트에 의해 결정됩니다.

기본값: ""

가져올 작업을 지정합니다.

기본값: ""
finalOptions: Dictionary

OnFinishRecording 에 전달할 값의 선택적 테이블.

기본값: ""

반환

()

코드 샘플

To commit an undo/redo record, you need to first call TryBeginRecording() followed by calling FinishRecording().

ChangeHistoryService:TryBeginRecording

local ChangeHistoryService = game:GetService("ChangeHistoryService")
local Selection = game:GetService("Selection")
local toolbar = plugin:CreateToolbar("Example Plugin")
local button = toolbar:CreateButton("Neon it up", "", "")
button.Click:Connect(function()
local parts = {}
for _, part in pairs(Selection:Get()) do
if part:IsA("BasePart") then
parts[#parts + 1] = part
end
end
if #parts < 1 then
-- Nothing to do.
return
end
local recording = ChangeHistoryService:TryBeginRecording("Set selection to neon")
if not recording then
-- Handle error here. This indidcates that your plugin began a previous
-- recording and never completed it. You may only have one recording
-- per plugin active at a time.
return
end
for _, part in pairs(parts) do
part.Material = Enum.Material.Neon
end
ChangeHistoryService:FinishRecording(recording, Enum.FinishRecordingOperation.Commit)
end)

GetCanRedo

플러그인 보안

되돌릴 수 있는 작업이 있는지 여부를 반환하고, 있으면 마지막 작업을 반환합니다.


반환

GetCanUndo

플러그인 보안

취소할 수 있는 작업이 있는지 여부를 반환하고, 있으면 마지막 작업을 반환합니다.


반환

IsRecordingInProgress

플러그인 보안

매개 변수

identifier: string
기본값: ""

반환

Redo

()
플러그인 보안

취소된 마지막 작업을 실행합니다.


반환

()

ResetWaypoints

()
플러그인 보안

기록을 지우고 모든 실행 취소/다시 실행 경로가 제거됩니다.


반환

()

SetEnabled

()
플러그인 보안

변경 내역 서비스를 활성화할지 여부를 설정합니다.거짓으로 설정되면 실행 취소/다시 실행 목록이 지워지고 재채워지지 않습니다.다시 진실로 설정되면 원래 목록은 복원되지 않지만 추가 작업이 목록에 다시 추가됩니다

매개 변수

state: boolean
기본값: ""

반환

()

SetWaypoint

()
플러그인 보안

이 메서드는 곧 사용되지 않을 것입니다 대신 TryBeginRecording() 에 대한 것입니다.

ChangeHistoryService 트랙은 속성 변경의 스트림으로 플러그인 기록을 추적합니다.SetWaypoint()는 이 속성 변경 스트림에서 잘라서 실행 취소 및 다시 실행 작업이 중지할 위치를 알 수 있도록 합니다.

규칙에 따라 Studio 의 사용자 발생 작업은 경험의 변경 세트를 완료한 후에 SetWaypoint()후에 호출해야 합니다.변경 내용 집합을 호출하기 전에 호출하면 경로 지점을 설정하지 못한 다른 오작동 플러그인이 정리될 수 있지만, 자체 플러그인에서 이러한 사용을 정당화하는 데 나쁜 이유입니다.

매개 변수

name: string
기본값: ""

반환

()

코드 샘플

In order for the waypoints to work correctly, you need to set one both before AND after you perform the action that should be able to be undone.

ChangeHistoryService:SetWaypoint

local ChangeHistoryService = game:GetService("ChangeHistoryService")
local Selection = game:GetService("Selection")
local toolbar = plugin:CreateToolbar("Example Plugin")
local button = toolbar:CreateButton("Neon it up", "", "")
button.Click:Connect(function()
local parts = {}
for _, part in pairs(Selection:Get()) do
if part:IsA("BasePart") then
parts[#parts + 1] = part
end
end
if #parts > 0 then
-- Calling SetWaypoint before the work will not cause any issues, however
-- it is redundant, only the call AFTER the work is needed.
--ChangeHistoryService:SetWaypoint("Setting selection to neon")
for _, part in pairs(parts) do
part.Material = Enum.Material.Neon
end
-- Call SetWaypoint AFTER completing the work
ChangeHistoryService:SetWaypoint("Set selection to neon")
else
-- Nothing to do. You do not need to call SetWaypoint in the case where
-- the action did not end up making any changes to the experience.
end
end)

TryBeginRecording

플러그인 보안

이 메서드는 데이터 모델의 변경 사항을 추적하기 위한 녹화를 시작합니다.변경 내용을 적용하기 전에 미래의 경고나 오류를 피하기 위해 호출해야 합니다( 해야 ).

녹음이 완료되면 반환된 녹음 식별자로 FinishRecording()를 호출하여 녹음을 완료하고 실행 취소/다시 실행 스택을 업데이트합니다.

이 메서드는 레코딩을 시작하지 못하면 nil 를 반환합니다.플러그인에 이미 진행 중인 레코딩이 있거나 사용자가 실행 또는 재생 모드에 있으면 레코딩이 실패합니다.

IsRecordingInProgress()를 사용하여 플러그인의 레코딩 상태를 확인할 수 있습니다.

매개 변수

name: string

로깅 및 코딩 목적에 적합한 행동의 이름.

기본값: ""
displayName: string

사용자에게 표시하기 위해 수행되는 작업의 이름.

기본값: ""

반환

코드 샘플

To commit an undo/redo record, you need to first call TryBeginRecording() followed by calling FinishRecording().

ChangeHistoryService:TryBeginRecording

local ChangeHistoryService = game:GetService("ChangeHistoryService")
local Selection = game:GetService("Selection")
local toolbar = plugin:CreateToolbar("Example Plugin")
local button = toolbar:CreateButton("Neon it up", "", "")
button.Click:Connect(function()
local parts = {}
for _, part in pairs(Selection:Get()) do
if part:IsA("BasePart") then
parts[#parts + 1] = part
end
end
if #parts < 1 then
-- Nothing to do.
return
end
local recording = ChangeHistoryService:TryBeginRecording("Set selection to neon")
if not recording then
-- Handle error here. This indidcates that your plugin began a previous
-- recording and never completed it. You may only have one recording
-- per plugin active at a time.
return
end
for _, part in pairs(parts) do
part.Material = Enum.Material.Neon
end
ChangeHistoryService:FinishRecording(recording, Enum.FinishRecordingOperation.Commit)
end)

Undo

()
플러그인 보안

방향점이 있는 마지막 행동을 취소합니다.


반환

()

이벤트

OnRecordingFinished

플러그인 보안

매개 변수

name: string

로깅 및 코딩 목적에 적합한 행동의 이름.

displayName: string

사용자에게 표시하기 위해 수행되는 작업의 이름.

identifier: string

레코딩의 식별자.

finalOptions: Dictionary

FinishOperation() 에서 선택적 테이블.


OnRecordingStarted

플러그인 보안

매개 변수

name: string

로깅 및 코딩 목적에 적합한 행동의 이름.

displayName: string

사용자에게 표시하기 위해 수행되는 작업의 이름.


OnRedo

플러그인 보안

사용자가 실행 취소 명령을 되돌릴 때 발생합니다. 웨이포인트는 다시 실행된 유형 작업을 설명합니다.

매개 변수

waypoint: string

OnUndo

플러그인 보안

사용자가 스튜디오에서 작업을 취소할 때 발생합니다. 웨이포인트는 취소된 작업 유형을 설명합니다.

매개 변수

waypoint: string