ChangeHistoryService

非推奨を表示

*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。

作成できません
サービス

プラグイン開発者 ChangeHistoryService を使用して、Studio がエクスペリエンスに変更を戻し、やり直すようにするためにプラグインが行う変更を記録する必要があります。変更する前に、プラグインは Class.ChangeHistoryService

プラグインは、ChangeHistoryService:Undo() または ChangeHistoryService:Redo() を通じて、取り消しまたはやり直しをプログラマチックに呼び出すこともできます。

ChangeHistoryService は、実行時にはオーバーロードされていないので、実行エクスペリエンスでメソッドを呼び出すことは影響しません。

概要

方法

  • FinishRecording(identifier : string,operation : Enum.FinishRecordingOperation,finalOptions : Dictionary?):void
    プラグインのセキュリティ

    スタジオに、特定のレコーディングが完了したことを通信し、最終オペレーションを完了するために取得します。

  • プラグインのセキュリティ

    、やり直すことができるアクションがあるかどうかを返し、ある場合は、最後のアクションを返します。

  • プラグインのセキュリティ

    取り消しできるアクションがあるかどうか、および、ある場合は、最後のアクションを返します。

  • プラグインのセキュリティ
  • Redo():void
    プラグインのセキュリティ

    最後に実行されたアクションを実行します。

  • プラグインのセキュリティ

    歴史をクリアし、すべての取り消し/やり直し方向点を削除します。

  • SetEnabled(state : bool):void
    プラグインのセキュリティ

    ChangeHistoryService が有効かどうかを設定します。

  • SetWaypoint(name : string):void
    プラグインのセキュリティ

    取り消しまたはやり直しポイントとして使用できる新しいウェイポイントを設定します。

  • TryBeginRecording(name : string,displayName : string?):string?
    プラグインのセキュリティ

    データモデルに変更を記録し始めます。

  • Undo():void
    プラグインのセキュリティ

    最後に実行されたアクションを取り消す。

イベント

プロパティ

方法

FinishRecording

void
プラグインのセキュリティ

パラメータ

identifier: string

以前の呼び出しから TryBeginRecording() にレコードを記録します。操作が Enum.ChangeHistoryService.FinishRecordingOperation.Cancel である場合、この値は無視され、レコードはコンテキストで決定されます。

実行するオペレーションを指定します。

finalOptions: Dictionary

オプションのテーブルの値を OnFinishRecording にパスします。


戻り値

void

コードサンプル

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

void
プラグインのセキュリティ

最後に実行されたアクションを実行します。


戻り値

void

ResetWaypoints

void
プラグインのセキュリティ

歴史をクリアし、すべての取り消し/やり直し方向点を削除します。


戻り値

void

SetEnabled

void
プラグインのセキュリティ

ChangeHistoryService が有効かどうかを設定します。ChangeHistoryService が false で設定されている場合、undo/redo リストがクリアされ、再び設定されません。ChangeHistoryService が true に設定されている場合、オリジナルリストは復元されませんが、次のオペレーションがリストに追加されます

パラメータ

state: bool

戻り値

void

SetWaypoint

void
プラグインのセキュリティ

このメソッドは、 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

パラメータ

name: string

戻り値

void

コードサンプル

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() を呼び出し、返されたレコーディング識別子で Class.ChangeHistoryService.FinishRecording()|FinishRecording() を完了し、取り消し/やり直しスタックを更新します。

このメソッドは、nil を返すことがあります。 Run または Play モードにユーザーがある場合、プラグインにはすでにレコーディングがあり、またはユーザーが 1>Run1> または 4>Play4> モードにある場合、レコーディングは開始できません。

Class.ChangeHistoryService.IsRecordingInProgress()|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

void
プラグインのセキュリティ

最後に実行されたアクションを取り消す。


戻り値

void

イベント

OnRecordingFinished

プラグインのセキュリティ

パラメータ

name: string

実行中のアクションの名前は、ログやコードの目的に適しています。

displayName: string

ユーザーに表示するアクションの名前。

identifier: string

レコーディングの識別子。

finalOptions: Dictionary

Class.ChangeHistoryService.FinishOperation()|FinishOperation() からオプションのテーブル。


OnRecordingStarted

プラグインのセキュリティ

パラメータ

name: string

実行中のアクションの名前は、ログやコードの目的に適しています。

displayName: string

ユーザーに表示するアクションの名前。


OnRedo

プラグインのセキュリティ

ユーザーが取り消しコマンドを戻したときに発動します。ウェイポイントは、実行しなおされたタイプアクションを記述します。

パラメータ

waypoint: string

OnUndo

プラグインのセキュリティ

ユーザーがスタジオでアクションを取り消したときに発動します。ウェイポイントは、取り消しされたアクションのタイプを説明します。

パラメータ

waypoint: string