public void SeekReplayHighlightsNormalized(float normalizedOffset) { if (isReplayingHighlights == true) { float totalDuration = 0; for (int i = 0; i < highlightsStorage.Count; i++) { totalDuration += highlightsStorage[i].Duration; } float targetTime = Mathf.Lerp(0, totalDuration, Mathf.Clamp01(normalizedOffset)); for (int i = 0; i < highlightsStorage.Count; i++) { if (targetTime < highlightsStorage[i].Duration) { ReplayManager.StopPlayback(ref replayHighlightHandle); replayHighlightHandle = ReplayManager.BeginPlayback(highlightsStorage[i]); ReplayManager.SetPlaybackTime(replayHighlightHandle, targetTime); break; } targetTime -= highlightsStorage[i].Duration; } } }
// Methods public IEnumerator Start() { // Create a record scene for the record object ReplayScene recordScene = new ReplayScene(recordObject); // Start recording the single object ReplayHandle recordHandle = ReplayManager.BeginRecording(null, recordScene); // Allow some data to be recorded for 1 second yield return(new WaitForSeconds(1f)); // Stop recording ReplayManager.StopRecording(ref recordHandle); // Clone the identity which allows the replayObject to be replayed as the recordObject ReplayObject.CloneReplayObjectIdentity(recordObject, replayObject); // Create a playback scene for the replay object ReplayScene playbackScene = new ReplayScene(replayObject); // Start playback ReplayManager.BeginPlayback(null, playbackScene); }
// Methods public IEnumerator Start() { // Usually you should register replay prefabs in editor via the global settings but it can also be done via code if required UltimateReplay.Settings.prefabs.RegisterReplayablePrefab(instanitatePrefab); // Start recording - Note that we need to enable 'allowEmptyScene' if there are no replay objects in the scene initially ReplayHandle recordHandle = ReplayManager.BeginRecording(null, null, true, true); // Wait for some time to pass yield return(new WaitForSeconds(1f)); // Spawn a dynamic replay object ReplayObject obj = Instantiate(instanitatePrefab); // Add the object to all recording scenes - This is a required step otherwise the object will not be recorded ReplayManager.AddReplayObjectToRecordScenes(obj); // Wait for some time to pass now that the object has been spawned yield return(new WaitForSeconds(1)); // End recording // The resulting replay will have 1 second of nothing and then the dynamic object will be re-instantiated by the replay system ReplayManager.StopRecording(ref recordHandle); }
private IEnumerator RestartKillcamRecording() { // Wait a frame yield return(null); // Start recording again killcamStorage.Clear(); killcamHandle = ReplayManager.BeginRecording(killcamStorage); }
// Methods public void Start() { // Create a memory storage target to store the replay ReplayStorageTarget storage = new ReplayMemoryTarget(); // Begin recording to the specified storage target. // We should store the returned replay handle as all other replay operations will expect this value as a parameter to identify the recording // By default, all replay objects in the active scene will be recorded. recordHandle = ReplayManager.BeginRecording(storage); }
// Methods public override void Awake() { base.Awake(); // Create a rolling memory buffer of 10 seconds killcamStorage = ReplayMemoryTarget.CreateTimeLimitedRolling(recordKillcamSeconds); // Start recording killcamHandle = ReplayManager.BeginRecording(killcamStorage); }
// Methods public IEnumerator Start() { // Record as normal ReplayHandle handle = ReplayManager.BeginRecording(new ReplayMemoryTarget()); // Allow recording to run for 1 second yield return(new WaitForSeconds(1f)); // Stop recording // We need to pass the handle to the recording as a reference which will cause the handle to become invalid ReplayManager.StopRecording(ref handle); }
public void ResetKillcam() { // Stop recording if (ReplayManager.IsRecording(killcamHandle) == true) { ReplayManager.StopRecording(ref killcamHandle); } killcamStorage.Clear(); killcamHandle = ReplayManager.BeginRecording(killcamStorage); }
// Methods public IEnumerator Start() { // Record as normal ReplayHandle handle = ReplayManager.BeginRecording(new ReplayMemoryTarget()); // Allow recording to run for 1 second yield return(new WaitForSeconds(1f)); // Pause recording // This will supend recording and we can resume at a later date so long as we have the replay handle object ReplayManager.PauseRecording(handle); }
public void Start() { // This example assumes that this stream already has valid replay data stored within it. // This could be any stream that supports reading, seeking and getting Position. MemoryStream stream = new MemoryStream(); // Create a replay stream target for the specified stream object ReplayStreamTarget replayStream = ReplayStreamTarget.CreateReplayStream(stream); // Start replaying from the stream ReplayHandle playbackHandle = ReplayManager.BeginPlayback(replayStream); }
public void ReplayHighlights() { if (replayHighlightIndex >= 0 && replayHighlightIndex < highlightsStorage.Count) { isReplayingHighlights = true; replayHighlightIndex = 0; // Start replaying highlights replayHighlightHandle = ReplayManager.BeginPlayback(highlightsStorage[replayHighlightIndex]); // Add listener for playback finished ReplayManager.AddPlaybackEndListener(replayHighlightHandle, OnHighlightPlaybackFinished); } }
// Methods public IEnumerator Start() { // Create a replay file target for the specified file path ReplayFileTarget recordFile = ReplayFileTarget.CreateReplayFile("C:/ReplayFiles/Example.replay"); // Start recording to the file ReplayHandle recordHandle = ReplayManager.BeginRecording(recordFile); // Allow some data to be recorded for 1 second yield return(new WaitForSeconds(1f)); // Stop recording - This will finalize the replay file, commit any buffered data and dispose of any open file streams. ReplayManager.StopRecording(ref recordHandle); }
public IEnumerator Start() { // Create a stream object of some form to hold the data. This could be any stream that supports writing, seeking and getting Position. MemoryStream stream = new MemoryStream(); // Create a replay stream target for the specified stream object ReplayStreamTarget recordStream = ReplayStreamTarget.CreateReplayStream(stream); // Start recording to the stream ReplayHandle recordHandle = ReplayManager.BeginRecording(recordStream); // Allow some data to be recorded for 1 second yield return(new WaitForSeconds(1f)); // Stop recording - This will finalize the replay file, commit any buffered data and dispose of any open file streams. ReplayManager.StopRecording(ref recordHandle); }
public void PlayKillcam() { // Stop recording if (ReplayManager.IsRecording(killcamHandle) == true) { ReplayManager.StopRecording(ref killcamHandle); } // Start replaying killcamHandle = ReplayManager.BeginPlayback(killcamStorage); isReplaying = true; // Activate camera killcamViewCamera.enabled = true; killcamViewCanvas.gameObject.SetActive(true); killcamViewCamera.GetComponent <AudioListener>().enabled = true; ReplayManager.AddPlaybackEndListener(killcamHandle, OnKillcamEnd); }
// Methods public IEnumerator Start() { for (int i = 0; i < 5; i++) { ReplayMemoryTarget storage = new ReplayMemoryTarget(); // Record some gameplay ReplayHandle handle = ReplayManager.BeginRecording(storage); // Wait for some data to be recorded yield return(new WaitForSeconds(3)); // End the recording ReplayManager.StopRecording(ref handle); // Add storage highlightsStorage.Add(storage); } }
// Methods public IEnumerator Start() { ReplayMemoryTarget storage = new ReplayMemoryTarget(); // Record as normal ReplayHandle handle = ReplayManager.BeginRecording(storage); // Allow recording to run for 1 second yield return(new WaitForSeconds(1f)); // Stop recording // We need to pass the handle to the recording as a reference which will cause the handle to become invalid ReplayManager.StopRecording(ref handle); // Begin playback of the recording that we captured in the storage target // Again this method will return a replay handle that is required for many other playback operations playbackHandle = ReplayManager.BeginPlayback(storage); }
private void OnHighlightPlaybackFinished() { // Increase storage index replayHighlightIndex++; if (replayHighlightIndex >= 0 && replayHighlightIndex < highlightsStorage.Count) { // Start replaying highlights replayHighlightHandle = ReplayManager.BeginPlayback(highlightsStorage[replayHighlightIndex]); // Add listener for playback finished ReplayManager.AddPlaybackEndListener(replayHighlightHandle, OnHighlightPlaybackFinished); } else { isReplayingHighlights = false; replayHighlightIndex = 0; replayHighlightHandle = ReplayHandle.invalid; } }
public void OnTriggerEnter(Collider other) { Debug.LogWarning("Trigger"); // Stop replaying if (ReplayManager.IsReplaying(playbackHandle) == true) { ReplayManager.StopPlayback(ref playbackHandle); } // Stop recording if (ReplayManager.IsRecording(recordHandle) == true) { // Stop recording ReplayManager.StopRecording(ref recordHandle); playbackStorage = recordStorage; recordStorage = new ReplayMemoryTarget(); Debug.Log("Recording Length: " + playbackStorage.Duration); // Enable the ghost car ghostCar.gameObject.SetActive(true); // Clone identities - This allows the ghost car to be replayed as the player car ReplayObject.CloneReplayObjectIdentity(playerCar, ghostCar); // Start replaying playbackHandle = ReplayManager.BeginPlayback(playbackStorage, playbackScene); // Add end playback listener ReplayManager.AddPlaybackEndListener(playbackHandle, OnGhostVehiclePlaybackComplete); } // Start recording recordHandle = ReplayManager.BeginRecording(recordStorage, recordScene); }
public IEnumerator StartAlternative() { // Create a replay scene from the active Unity scene ReplayScene recordScene = ReplayScene.FromCurrentScene(); // Start recording ReplayHandle recordHandle = ReplayManager.BeginRecording(null, recordScene); // Wait for some time to pass yield return(new WaitForSeconds(1f)); // Spawn a dynamic replay object ReplayObject obj = Instantiate(instanitatePrefab); // Add the object to the record scene only - This is a required step otherwise the object will not be recorded recordScene.AddReplayObject(obj); // Wait for some time to pass now that the object has been spawned yield return(new WaitForSeconds(1)); // End recording // The resulting replay will have 1 second of nothing and then the dynamic object will be re-instantiated by the replay system ReplayManager.StopRecording(ref recordHandle); }