ChangeHistoryService
*이 콘텐츠는 AI(베타)를 사용해 번역되었으며, 오류가 있을 수 있습니다. 이 페이지를 영어로 보려면 여기를 클릭하세요.
플러그인 개발자는 을 사용해야 합니다. Class.ChangeHistoryService 에서 Studio에 플러그인이 경험에 적용하는 변경 사항을 실행하는 방법을 알려주기 위해 하기 전에 플러그인이 호출하는 Class.ChangeHistoryService
플러그인은 또한 Class.ChangeHistoryService:Undo() 또는 Class.ChangeHistoryService:Redo를 통해 실행 취소 또는 다시 실행을 프로그래밍적으로 호출할 수 있습니다.
ChangeHistoryService는 런타임에 사용할 수 없으므로 실행 경험에서 메서드를 호출하는 것은 효과가 없습니다.
요약
메서드
- FinishRecording(identifier : string,operation : Enum.FinishRecordingOperation,finalOptions : Dictionary?):void
식별된 레코딩이 완료되었음을 Studio에 알려주고 마지막 작업을 완료하여 레코딩을 완료합니다.
실행할 수 있는 동작이 있는지 여부를 반환하고, 있으면 마지막 동작을 반환합니다.
실행 취소할 수 있는 동작이 있는지 여부를 반환하고, 있으면 마지막을 반환합니다.
실행 취소된 마지막 작업을 실행합니다.
기록을 지우고 모든 실행 취소/다시 실행 경로를 제거합니다.
ChangeHistoryService가 활성화되어 있는지 여부를 설정합니다.
실행 취소 또는 다시 실행할 때 사용할 수 있는 새로운 위치를 설정합니다.
데이터 모델에 변경 내용을 기록으로 시작합니다.
마지막에 수행한 작업을 실행 취소 하 여, 해당 위치에 대 한 방법이 있습니다.
이벤트
- OnRecordingFinished(name : string,displayName : string?,identifier : string?,operationn : Enum.FinishRecordingOperation,finalOptions : Dictionary?):RBXScriptSignal
사용자가 액션완료할 때 발생합니다. 매개 변수는 TryBeginRecording() 및 FinishRecording()에서 나옵니다.
사용자가 액션시작할 때 발생합니다. 매개 변수는 TryBeginRecording() 에서 옵니다.
사용자가 실행 취소 명령을 되돌렸을 때 발생했습니다. Waypoint는 다시 실행된 형식 작업을 설명합니다.
사용자가 스튜디오에서 작업을 취소할 때 발생합니다. Waypoint는 취소된 작업의 유형을 설명합니다.
속성
메서드
FinishRecording
매개 변수
이전 호출에서 레코딩을 TryBeginRecording() 로 식별합니다. 작업이 Enum.ChangeHistoryService.FinishRecordingOperation.Cancel 인 경우 이 값이 무시되고 레코딩이 컨텍스트에 따라 결정됩니다.
수행할 작업을 지정합니다.
Class.ChangeHistoryService.OnFinishRecording|OnFinishRecording에 대한 옵션 테이블 값을 전달합니다.
반환
코드 샘플
To commit an undo/redo record, you need to first call TryBeginRecording() followed by calling FinishRecording().
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)
Redo
실행 취소된 마지막 작업을 실행합니다.
반환
ResetWaypoints
기록을 지우고 모든 실행 취소/다시 실행 경로를 제거합니다.
반환
SetEnabled
ChangeHistoryService가 활성화되었는지 여부를 설정합니다. 변경 내역 서비스가 사용 안 함으로 설정되면 실행 취소/다시 실행 목록이 비워지고 다시 채우지 않습니다. 변경 내역 서비스가 다시 사용 되도록 설정되면 원래 목록이 다시 복원되지 않고 다시 작업이 목록에 더해집니다.
매개 변수
반환
SetWaypoint
이 메서드는 곧 지원되지 않습니다. 대신 TryBeginRecording() 에 사용됩니다.
ChangeHistoryService 는 속성 변경의 스트림을 플러그인 기록으로 추적합니다. SetWaypoint() 는 해당 스트림의 속성 변경을 절단하여 실행 취소 및 다시 실행 작업이 어디에 중지할지 알려줍니다.
By 규칙, Studio에서 사용자 호출 작업은 해당 경험에 대한 변경 내용을 완료한 후에만SetWaypoint() 을 호출할 수 있습니다. 이 작업을 Before 변경 내용을 완료
매개 변수
반환
코드 샘플
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.
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 을 반환합니다. 레코딩은 플러그인이 이미 레코딩을 시작했거나 사용자가 Run 또는 Play 모드에 있는 경우에만 실패합니다.
Class.ChangeHistoryService.IsRecordingInProgress()|IsRecordingInProgress() 를 사용하여 플러그인의 녹음 상태를 확인할 수 있습니다.
매개 변수
반환
코드 샘플
To commit an undo/redo record, you need to first call TryBeginRecording() followed by calling FinishRecording().
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
매개 변수
로깅 및 코딩 목적으로 적절한 동작의 이름.
사용자에게 표시할 동작의 이름입니다.
녹음에 대한 식별자.
Class.ChangeHistoryService.FinishOperation()|FinishOperation() 의 옵션 테이블.