ChangeHistoryService
*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。
プラグイン開発者 は ChangeHistoryService を使用して、Studio がエクスペリエンスに変更を戻し、やり直すようにするためにプラグインが行う変更を記録する必要があります。変更する前に、プラグインは Class.ChangeHistoryService
プラグインは、ChangeHistoryService:Undo() または ChangeHistoryService:Redo() を通じて、取り消しまたはやり直しをプログラマチックに呼び出すこともできます。
ChangeHistoryService は、実行時にはオーバーロードされていないので、実行エクスペリエンスでメソッドを呼び出すことは影響しません。
概要
方法
- FinishRecording(identifier : string,operation : Enum.FinishRecordingOperation,finalOptions : Dictionary?):void
スタジオに、特定のレコーディングが完了したことを通信し、最終オペレーションを完了するために取得します。
、やり直すことができるアクションがあるかどうかを返し、ある場合は、最後のアクションを返します。
取り消しできるアクションがあるかどうか、および、ある場合は、最後のアクションを返します。
最後に実行されたアクションを実行します。
歴史をクリアし、すべての取り消し/やり直し方向点を削除します。
ChangeHistoryService が有効かどうかを設定します。
取り消しまたはやり直しポイントとして使用できる新しいウェイポイントを設定します。
データモデルに変更を記録し始めます。
最後に実行されたアクションを取り消す。
イベント
- OnRecordingFinished(name : string,displayName : string?,identifier : string?,operationn : Enum.FinishRecordingOperation,finalOptions : Dictionary?):RBXScriptSignal
ユーザーがアクショ操作を完了すると、パラメーターは TryBeginRecording() から、および FinishRecording() から来ます。
ユーザーがアクション操作開始すると、パラメーターは TryBeginRecording() から来ます。
ユーザーが取り消しコマンドを戻したときに発動します。ウェイポイントは、実行しなおされたタイプアクションを記述します。
ユーザーがスタジオでアクションを取り消したときに発動します。ウェイポイントは、取り消しされたアクションのタイプを説明します。
プロパティ
方法
FinishRecording
パラメータ
以前の呼び出しから TryBeginRecording() にレコードを記録します。操作が Enum.ChangeHistoryService.FinishRecordingOperation.Cancel である場合、この値は無視され、レコードはコンテキストで決定されます。
実行するオペレーションを指定します。
オプションのテーブルの値を 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 が有効かどうかを設定します。ChangeHistoryService が false で設定されている場合、undo/redo リストがクリアされ、再び設定されません。ChangeHistoryService が true に設定されている場合、オリジナルリストは復元されませんが、次のオペレーションがリストに追加されます
パラメータ
戻り値
SetWaypoint
このメソッドは、 Class.ChangeHistoryService:TryBeginRecording()|TryBeginRecording() の代わりに Class.ChangeHistoryService:Deprecate() になります。
ChangeHistoryService は、プラグインの履歴をストリームのプロパティ変更として追跡します。 SetWaypoint() は、undo と redo アクションがどこに停止するかを知るために、そのプラグインの履歴を切り替えます。
By convention, user-invoked actions in Studio must call SetWaypoint() 後 after 完了した変更のセットをエクスペリエンスに。Calling it 1> before1> a set of changes may clean up another misbehaving plugin which failed to set a waypoint, but it's a poor
パラメータ
戻り値
コードサンプル
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() を呼び出し、返されたレコーディング識別子で Class.ChangeHistoryService.FinishRecording()|FinishRecording() を完了し、取り消し/やり直しスタックを更新します。
このメソッドは、nil を返すことがあります。 Run または Play モードにユーザーがある場合、プラグインにはすでにレコーディングがあり、またはユーザーが 1>Run1> または 4>Play4> モードにある場合、レコーディングは開始できません。
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() からオプションのテーブル。