This is a project that provides an extension to Unity's API to enable recording and playback of runtime calls by serializing and storing them. Playback is achieved by restoring calls based on timestamps. The goal is to support replay functionality for the majority of commonly used APIs that affect visual presentation, with minimal modifications.
- Recording and playback of the complete lifecycle of prefabs from instantiation to destruction.
- Recording of changes to scene objects.
- Start and stop recording at any time.
- When starting recording or playback, any prefabs created will be cleared, and some initial state of scene objects will be restored.
- Playback supports using TimeScale to achieve pause, acceleration, and deceleration effects. However, due to unpredictable animations, precise time skipping is not perfectly supported.
- APIs called frame by frame, such as movement and rotation, support frame reduction compression to optimize storage size. The final files can also be compressed and encrypted.
- Custom method calls can be recorded and played back.
-
Attach the
ReplayableUnitscript to scene objects and prefabs that need to be recorded and played back. This script records references to all components on the object and its child objects. After making modifications to such objects, click "Refresh References" in the Inspector panel. Certain modifications may invalidate previously recorded replays. -
Place the
ReplayableManagerin the scene. -
Add the prefabs and runtime reference instances used by all
ReplayableUnitscripts toReplayableManager/ReferenceManager(script)/references(List). -
Replace Unity API calls with the corresponding replayable APIs listed below.
-
For more details on principles and usage, refer to the example scenes.
Replace the following Unity APIs with their corresponding replayable APIs:
