Ultimate Replay Scripting Reference
ReplayManager Class |
The main interface for Ultimate Replay and allows full control over object recording and playback.
Inheritance Hierarchy
SystemObject Object
Component
Behaviour
MonoBehaviour
UltimateReplay.UtilMonoSingletonReplayManager
UltimateReplayReplayManager
Component
Behaviour
MonoBehaviour
UltimateReplay.UtilMonoSingletonReplayManager
UltimateReplayReplayManager
Namespace: UltimateReplay
Assembly: UltimateReplay (in UltimateReplay.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
public sealed class ReplayManager : MonoSingleton<ReplayManager>
The ReplayManager type exposes the following members.
Constructors
Name | Description | |
---|---|---|
ReplayManager | Initializes a new instance of the ReplayManager class |
Methods
Name | Description | |
---|---|---|
BeginPlayback |
Use this method to begin the playback of the recorded objects.
Use SetPlaybackFrame(Single, PlaybackOrigin) or SetPlaybackFrameNormalized(Single, PlaybackOrigin) before calling this method to specify the exact location at which playback should begin.
This method will run the entire playback gathered and then automatically stop playback on completion if endReplayAfterPlayback is true.
| |
BeginPlaybackFrame |
Use this method to set the current playback at a specific replay frame.
This will allow the state of a specific replay frame to be restored but will not continue playback which will provide a freeze frame effect.
Use SetPlaybackFrame(Single, PlaybackOrigin) or SetPlaybackFrameNormalized(Single, PlaybackOrigin) before calling this method to specify the exact location at which the playback frame should be sampled.
Use StopPlayback to unfreeze the still frame and return to normal game mode.
This method will ignore the value of endReplayAfterPlayback as only a single frame is replayed. As a result you will need to call StopPlayback when you want to end the playback frame.
| |
BeginRecording |
Use this method to begin sampling the recorded objects in the scene.
If recordOnStart is true then this method will be called automatically when the manager is initialized.
Any state information will be recored via the assigned ReplayTarget (Default ReplayMemoryTarget).
When true, any previous recording data will be discarded | |
DiscardRecording |
This method will throw away any recorded data and flush the replay target if necessary.
This method can be called at any time.
If the manager is currently recording then all previous data will be discarded and recording will continue.
If the manager is currently replaying then all replay data will be discarded and playback will stop.
| |
FindReplayPrefab |
Attempts to find the prefab with the matching name.
This is used to restore objects that were destroyed during recording.
| |
ForceAwake |
Override implementation of ForceAwake.
Performs exactly the same behaviour.
Simply included so that the user does not need to import 'UltimateReplay.Util' to access the method.
| |
OnDestroy |
Called by Unity.
Allows the active replay manager to cleanup any active recordings.
| |
OnLevelWasLoaded |
Called by Unity.
Allows the active replay manager to cleanup recordings when a scene change is made.
| |
OnValidate |
Called by Unity.
| |
PausePlayback |
Use this method to pause replay playback while maintinaing the current replay state.
See ResumePlayback to continue a playback.
| |
PauseRecording |
Use this method when you want to pause recording but may continue recording at any point.
A good candidate for pausing recording is when the user pauses the game and is shown a pause menu.
The manager must already be recording otherwise this method will have no effect.
| |
RegisterReplayPrefab |
Attempts to register a game object as a prefab so that the replay system is able to spawn or despawn the object as needed.
You only need to do this for objects that are likley to be either instantiated or destroyed during recording.
The replay system will then be able to accuratley restore the scene state during playback.
The specified object must be a prefab otherwise an error will be thrown and the object will not be registered.
Prefab instances are not accepted.
| |
ReplayDestroy |
Attempts to destroy the specified prefab.
OnReplayDestroy will be called if a listener has been registered otherwise default destruction will be used.
| |
ReplayInstantiate |
Attempts to instantiate the specified prefab.
OnReplayInstantiate will be called if a listener has been registered otherwise default instantiation will be used.
| |
ResumePlayback |
Use this method to resume playback after a previous call to PausePlayback was called.
If PausePlayback was not called prior to this method then the method will have no effect.
| |
ResumeRecording |
Use this method to resume recording after a previous call to PauseRecording.
The manager must already be recording otherwise this method will have no effect.
| |
SetPlaybackFrame |
Use this method to specify where in the replay sequence the playback should start.
If the offset does not lie within the bounds of the replay then the value will be clamped to represent either the start or end frame.
| |
SetPlaybackFrameNormalized |
Use this method to specify where in the replay sequence the playback should start.
This method accepts normalized offsets values between 0 and 1 and performs validation before using the value.
| |
Start |
Called by Unity.
Allows the active replay manager to initialize.
| |
StopPlayback |
Use this method to stop any active playback.
This method will only have an effect if there is an active playback running otherwise it will have no effect.
| |
StopRecording |
Use this method to stop recording after a previous call to BeginRecording(Boolean).
The manager must already be recording otherwise this method will have no effect.
This method must be called before attempting to playback otherwise you may get unpredicatable results.
| |
Update |
Called by Unity.
Allows the active replay manager to update recoring or playback.
|
Fields
Name | Description | |
---|---|---|
endReplayAfterPlayback |
When true, the replay manager will automatically restore the previous game state after playback has finished.
When false, playback will continue to loop forever until a suitable stop or pause command is issued manually.
| |
OnReplayDestroy |
Called by the replay system whenever it needs to destroy a game object in order to restore a previous scene state.
You can add a listener to override the default behaviour which can be useful if you want to handle the destruction manually for purposes such as object pooling.
| |
OnReplayInstantiate |
Called by the replay system whenever it needs to instantiate a prefab for use during playback.
You can add a listener to override the default behaviour which can be useful if you want to handle the instantiation manually for purposes such as object pooling.
| |
prefabs |
A collection of prefabs that may be spawned or destroyed during recording and as a result amy need to be spawned or destroyed in order to accuratley recreate the replay.
| |
recordFPS |
The target record framerate of the sampler. The higher this value the higher the memory consumption and cpu usage will be.
You will need to fine tune this value to tradeoff performance or memory usage for replay accuracy.
| |
recordOnStart |
When true, the manager will automatically begin recording the scene one it is initialized.
|
Properties
Name | Description | |
---|---|---|
CurrentPlaybackTime |
Get the current playback time in seconds.
This value will never be greater than duration.
| |
CurrentPlaybackTimeNormalized |
Get the current playback time as a normalized value between 0-1.
0 represents the starting frame of the recording and 1 represents the very last frame of the recording.
| |
IsPaused |
Returns true when the active replay manager is in any paused state.
Paused states could include Playback_Paused or Recording_Paused.
| |
IsRecording |
Returns true if the manager is currently recording the scene.
Note: If recording is paused this value will still be true.
| |
IsReplaying |
Returns true if the manager is currently playing back previously recorded replay data.
Note: if playback is paused this value will still be true.
| |
PlaybackDirection |
Gets the current PlaybackDirection of replay playback.
| |
Preparer |
Access the current IReplayPreparer that the active replay manager will use to prepare game objects for replay.
By default a DefaultReplayPreparer is used.
| |
Replay |
Get the active replay manager in the scene.
If no replay manager could be found then one will be created with default settings.
This property may be null in a rare case where the active replay manager was destroyed in the same frame as an application quit event was issued. In this situation the replay manager cannot be recreated as it would cause leaked objects.
| |
Scene |
Get the ReplayScene associated with the replay system.
| |
Target |
The current replay target that is being used to store the replay data.
By default, the replay target is ReplayMemoryTarget.
|
See Also