/// <summary> /// Clears all state information for the current recording essentially restoring the memory target to its initial state. /// </summary> public override void PrepareTarget(ReplayTargetTask mode) { // Only listen for discard events - We can switch between read and write instantly if (mode == ReplayTargetTask.Discard) { // Clear all recorded data states.Clear(); duration = 0; } else if (mode == ReplayTargetTask.Commit) { // Modify the snapshot time stamps so that the recording is 0 offset based if (states.Count > 0) { // Get the timestamp of the first frame float offsetTime = states[0].TimeStamp; // Deduct the time stamp from all other frames to make them offset based on 0 time foreach (ReplaySnapshot snapshot in states) { snapshot.CorrectTimestamp(-offsetTime); } } } else if (mode == ReplayTargetTask.PrepareWrite) { #if UNITY_5_3_OR_NEWER // Get the current scene name sceneName = SceneManager.GetActiveScene().name; #else // Get the current scene name sceneName = Application.loadedLevelName; #endif } }
/// <summary> /// Called by the recording system to notify the active <see cref="ReplayTarget"/> of an upcoming event. /// </summary> /// <param name="mode">The <see cref="ReplayTargetTask"/> that the target should prepare for</param> public abstract void PrepareTarget(ReplayTargetTask mode);