Barriers record and restore game state according to the options provided, and they can be used at the end of asynchronous events, in order to restore a recorded state. For example, you can use a barrier at the end of a preloader screen.
UnityEngine.Random class state will be recorded during capture and restored during replay at the point barrier is called. After this barrier, the same random numbers sequences will be generated when random numbers are taken from
The barrier type is used to synchronise frames at specific moments in code. This becomes especially useful when certain parts of the capture may take less or more time when replayed.
Consider a preloader which may take more or less time on different platforms and devices.
- Preloader takes longer to load during replay - the number of frames recorded at the barrier will be higher in the replay than in the capture. In this case, the frames will not be restored and the replay will continue from where the barrier was set.
- Preloader takes longer to load during capture - the number of frames recorded at the barrier will be lower in the replay than in the capture. In this case, all frames until the barrier will be skipped and the replay will continue from here.