ChangeHistoryService
Must be used by plugins to communicate to Studio how to undo and redo the changes which they make to the experience.
| Memory category | Instances |
|---|
Member index 14
Description
Plugin developers must use ChangeHistoryService to tell Studio how to undo and redo changes that their plugins make to experiences by recording. Before making changes, a plugin calls ChangeHistoryService:TryBeginRecording(), remembering the identifier it assigns, then after making changes, the Plugin calls ChangeHistoryService:FinishRecording() to complete the recording.
Plugins may also programmatically invoke an undo or redo through ChangeHistoryService:Undo() or ChangeHistoryService:Redo().
ChangeHistoryService is not enabled at runtime, so calling its methods in a running experience has no effect.
History 44
- 658 Change Parameters of OnRecordingFinished from (name: string, displayName: string?, identifier: string?, operationn: FinishRecordingOperation, finalOptions: Dictionary?) to (name: string, displayName: string?, identifier: string?, operation: FinishRecordingOperation, finalOptions: Dictionary?)
- 583 Add OnRecordingStarted
- 583 Add OnRecordingFinished
- 583 Add TryBeginRecording
- 583 Add IsRecordingInProgress
- 583 Add FinishRecording
- 573 Change ReturnType of Undo from void to null
- 573 Change ReturnType of SetWaypoint from void to null
- 573 Change ReturnType of SetEnabled from void to null
- 573 Change ReturnType of ResetWaypoints from void to null
- 573 Change ReturnType of Redo from void to null
- 462 Change ThreadSafety of OnUndo from to Unsafe
- 462 Change ThreadSafety of OnRedo from to Unsafe
- 462 Change ThreadSafety of Undo from to Unsafe
- 462 Change ThreadSafety of SetWaypoint from to Unsafe
- 462 Change ThreadSafety of SetEnabled from to Unsafe
- 462 Change ThreadSafety of ResetWaypoints from to Unsafe
- 462 Change ThreadSafety of Redo from to Unsafe
- 462 Change ThreadSafety of GetCanUndo from to Unsafe
- 462 Change ThreadSafety of GetCanRedo from to Unsafe
- 193 Add OnUndo
- 193 Add OnRedo
- 151 Change Security of Undo from security1 to PluginSecurity
- 151 Change Security of SetWaypoint from security1 to PluginSecurity
- 151 Change Security of SetEnabled from security1 to PluginSecurity
- 151 Change Security of ResetWaypoints from security1 to PluginSecurity
- 151 Change Security of Redo from security1 to PluginSecurity
- 151 Change Security of GetCanUndo from security1 to PluginSecurity
- 151 Change Security of GetCanRedo from security1 to PluginSecurity
- 150 Change Security of Undo from LocalUserSecurity to security1
- 150 Change Security of SetWaypoint from LocalUserSecurity to security1
- 150 Change Security of SetEnabled from LocalUserSecurity to security1
- 150 Change Security of ResetWaypoints from LocalUserSecurity to security1
- 150 Change Security of Redo from LocalUserSecurity to security1
- 150 Change Security of GetCanUndo from LocalUserSecurity to security1
- 150 Change Security of GetCanRedo from LocalUserSecurity to security1
- 47 Add Undo
- 47 Add SetWaypoint
- 47 Add SetEnabled
- 47 Add ResetWaypoints
- 47 Add Redo
- 47 Add GetCanUndo
- 47 Add GetCanRedo
- 47 Add ChangeHistoryService
Members 14
FinishRecording
| Parameters (3) | ||
|---|---|---|
| identifier | string | |
| operation | FinishRecordingOperation | |
| finalOptions | Dictionary? | |
| Returns (1) | ||
| null | ||
Completes a recording that was started with
TryBeginRecording(). Pass
the identifier returned by that call along with an
FinishRecordingOperation describing what to do with the recorded
changes:
- FinishRecordingOperation.Commit adds the changes to the undo/redo history as a new waypoint.
- FinishRecordingOperation.Cancel discards the recording and
reverts the changes it captured. The
identifieris ignored for this operation, so a plugin can cancel its own in-progress recording without knowing the identifier. - FinishRecordingOperation.Append merges the recording into the waypoint that immediately precedes it rather than creating a new one.
When the recording finishes, this method fires
OnRecordingFinished,
forwarding the finalOptions table. It raises an error if the calling
plugin has no recording in progress, or if operation is not
FinishRecordingOperation.Cancel and identifier does not match the
active recording. It has no effect when the service is disabled or while
an undo or redo is in progress.
| Security | PluginSecurity |
|---|---|
| Thread safety | Unsafe |
History 1
- 583 Add FinishRecording
GetCanRedo
| Parameters (0) | ||
|---|---|---|
| No parameters. | ||
| Returns (1) | ||
| Tuple | ||
Reports whether Redo() currently has
an action available to replay. It returns a boolean that is true when a
redoable waypoint exists ahead of the current position in the undo/redo
history; when that boolean is true, it also returns the name of the
waypoint that the next redo would replay.
The boolean is false, with no name returned, when the redo stack is
empty because the newest waypoint is already the current one, or when the
service is disabled (which is always the case at runtime).
| Security | PluginSecurity |
|---|---|
| Thread safety | Unsafe |
History 4
- 462 Change ThreadSafety of GetCanRedo from to Unsafe
- 151 Change Security of GetCanRedo from security1 to PluginSecurity
- 150 Change Security of GetCanRedo from LocalUserSecurity to security1
- 47 Add GetCanRedo
GetCanUndo
| Parameters (0) | ||
|---|---|---|
| No parameters. | ||
| Returns (1) | ||
| Tuple | ||
Reports whether Undo() currently has
an action available to revert. It returns a boolean that is true when an
undoable waypoint exists at the current position in the undo/redo history;
when that boolean is true, it also returns the name of the waypoint that
the next undo would revert.
The boolean is false, with no name returned, when the undo stack is
empty because the position is already at the base waypoint, or when the
service is disabled (which is always the case at runtime).
| Security | PluginSecurity |
|---|---|
| Thread safety | Unsafe |
History 4
- 462 Change ThreadSafety of GetCanUndo from to Unsafe
- 151 Change Security of GetCanUndo from security1 to PluginSecurity
- 150 Change Security of GetCanUndo from LocalUserSecurity to security1
- 47 Add GetCanUndo
IsRecordingInProgress
| Parameters (1) | ||
|---|---|---|
| identifier | string? | |
| Returns (1) | ||
| bool | ||
Reports whether the calling plugin has a recording in progress that was started with TryBeginRecording().
When called without an identifier, it returns true if any recording is
active for the plugin. When an identifier is supplied, it returns true
only if the active recording's identifier matches that value. It returns
false when the service is disabled or when the plugin has no active
recording.
| Security | PluginSecurity |
|---|---|
| Thread safety | Unsafe |
History 1
OnRecordingFinished
| Parameters (5) | |
|---|---|
| name | string |
| displayName | string? |
| identifier | string? |
| operation | FinishRecordingOperation |
| finalOptions | Dictionary? |
Fires when a recording started with
TryBeginRecording() is
completed through
FinishRecording(). The
operation argument reports how the recording was finished (Commit,
Cancel, or Append), and finalOptions is the optional table that was
passed to FinishRecording().
| Security | PluginSecurity |
|---|---|
| Thread safety | Unsafe |
History 2
- 658 Change Parameters of OnRecordingFinished from (name: string, displayName: string?, identifier: string?, operationn: FinishRecordingOperation, finalOptions: Dictionary?) to (name: string, displayName: string?, identifier: string?, operation: FinishRecordingOperation, finalOptions: Dictionary?)
- 583 Add OnRecordingFinished
OnRecordingStarted
| Parameters (2) | |
|---|---|
| name | string |
| displayName | string? |
Fires when a plugin begins a recording with
TryBeginRecording(),
carrying the same name and displayName values that were passed to that
call.
| Security | PluginSecurity |
|---|---|
| Thread safety | Unsafe |
History 1
OnRedo
| Parameters (1) | |
|---|---|
| waypoint | string |
Fires immediately after Redo() replays
a waypoint, whether the redo was triggered by the user through Studio or
invoked programmatically. The waypoint argument is the name of the
action that was redone, matching the name that was recorded for that
waypoint.
| Security | PluginSecurity |
|---|---|
| Thread safety | Unsafe |
OnUndo
| Parameters (1) | |
|---|---|
| waypoint | string |
Fires immediately after Undo() reverts
a waypoint, whether the undo was triggered by the user through Studio or
invoked programmatically. The waypoint argument is the name of the
action that was undone, matching the name that was recorded for that
waypoint.
| Security | PluginSecurity |
|---|---|
| Thread safety | Unsafe |
Redo
| Parameters (0) | ||
|---|---|---|
| No parameters. | ||
| Returns (1) | ||
| null | ||
Replays the waypoint immediately ahead of the current position in the undo/redo history, redoing the action that a matching Undo() had reverted, and advances the redo pointer forward by one waypoint. After the waypoint is replayed, it fires OnRedo with the name of the redone waypoint.
This method raises an error if a play is already in progress, if the service is disabled (which is always the case at runtime), or if there is nothing left to redo. Call GetCanRedo() first to confirm a redo is available.
| Security | PluginSecurity |
|---|---|
| Thread safety | Unsafe |
ResetWaypoints
| Parameters (0) | ||
|---|---|---|
| No parameters. | ||
| Returns (1) | ||
| null | ||
Records the current state as a waypoint named base and then merges every
existing waypoint into that single waypoint, leaving no actions to undo or
redo. Use this to establish a clean starting point so that later
Undo() calls cannot revert past the
current state.
This method has no effect when the service is disabled (which is always the case at runtime).
| Security | PluginSecurity |
|---|---|
| Thread safety | Unsafe |
History 5
- 573 Change ReturnType of ResetWaypoints from void to null
- 462 Change ThreadSafety of ResetWaypoints from to Unsafe
- 151 Change Security of ResetWaypoints from security1 to PluginSecurity
- 150 Change Security of ResetWaypoints from LocalUserSecurity to security1
- 47 Add ResetWaypoints
SetEnabled
| Parameters (1) | ||
|---|---|---|
| state | bool | |
| Returns (1) | ||
| null | ||
Sets whether or not the ChangeHistoryService is enabled. When set to false, the undo/redo list is cleared, and does not repopulate. When set to true again, the original list is not restored, but further operations append to the list once more
| Security | PluginSecurity |
|---|---|
| Thread safety | Unsafe |
History 5
- 573 Change ReturnType of SetEnabled from void to null
- 462 Change ThreadSafety of SetEnabled from to Unsafe
- 151 Change Security of SetEnabled from security1 to PluginSecurity
- 150 Change Security of SetEnabled from LocalUserSecurity to security1
- 47 Add SetEnabled
SetWaypoint
| Parameters (1) | ||
|---|---|---|
| name | string | |
| Returns (1) | ||
| null | ||
This method will be deprecated soon in favor of TryBeginRecording().
ChangeHistoryService tracks plugin history as a stream of property changes. SetWaypoint() creates a cut in that stream of property changes so that the undo and redo actions know where to stop.
By convention, user-invoked actions in Studio must call SetWaypoint() after completing their set of changes to the experience. Calling it before a set of changes may clean up another misbehaving plugin which failed to set a waypoint, but it's a poor reason to justify such usage in your own plugin.
| Security | PluginSecurity |
|---|---|
| Thread safety | Unsafe |
History 5
- 573 Change ReturnType of SetWaypoint from void to null
- 462 Change ThreadSafety of SetWaypoint from to Unsafe
- 151 Change Security of SetWaypoint from security1 to PluginSecurity
- 150 Change Security of SetWaypoint from LocalUserSecurity to security1
- 47 Add SetWaypoint
TryBeginRecording
| Parameters (2) | ||
|---|---|---|
| name | string | |
| displayName | string? | |
| Returns (1) | ||
| string? | ||
This method begins a recording to track changes to the data model. You must call it prior to making changes to avoid future warnings or errors.
When the recording is completed, you call FinishRecording() with the returned recording identifier to complete the recording and update the undo/redo stack.
This method will return nil if it fails to begin a recording. Recordings
fail if the plugin already has a recording in progress, or if the user is
in a solo playtest.
You may use IsRecordingInProgress() to check the recording status of the plugin.
| Security | PluginSecurity |
|---|---|
| Thread safety | Unsafe |
History 1
- 583 Add TryBeginRecording
Undo
| Parameters (0) | ||
|---|---|---|
| No parameters. | ||
| Returns (1) | ||
| null | ||
Unplays the waypoint at the current position in the undo/redo history, reverting the most recent recorded action, and steps the undo pointer back by one waypoint. After the waypoint is reverted, it fires OnUndo with the name of the undone waypoint.
This method raises an error if a play is already in progress, if the service is disabled (which is always the case at runtime), or if there is nothing left to undo. Call GetCanUndo() first to confirm an undo is available.
| Security | PluginSecurity |
|---|---|
| Thread safety | Unsafe |