Exemplo n.º 1
0
        /// <summary>
        /// Takes everything the recorder has seen so far and builds a recording from it, without stopping the recording process.
        /// </summary>
        /// <returns>A recording representing everything we've seen up until this point in time.</returns>
        /// <exception cref="System.InvalidOperationException">Thrown when the recorder is stopped.</exception>
        public Recording BuildRecording()
        {
            if (CurrentlyStopped())
            {
                throw new System.InvalidOperationException("Not recording anything! Nothing to build!");
            }

            if (CurrentlyPaused())
            {
                pauseSlices.Add(new Vector2(timePaused, Time.time));
            }

            var recordings = new SubjectRecording[subjectsToRecord.Count];

            for (int i = 0; i < recordings.Length; i++)
            {
                recordings[i] = subjectsToRecord[i].Save(timeStarted, Time.time, pauseSlices);
            }
            Recording recording = Recording.CreateInstance(recordings, CaptureUtil.FilterAndShift(customEvents, timeStarted, Time.time, pauseSlices), metadata);

            if (CurrentlyPaused())
            {
                pauseSlices.RemoveAt(pauseSlices.Count - 1);
            }
            return(recording);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Takes what events have been witnessed up until now and builds a recording from them.
 /// </summary>
 /// <param name="startTime">The minimum timestamp the events must have.</param>
 /// <param name="endTime">The maximum timestamp the events can have.</param>
 /// <param name="pauseSlices">Any time ranges you want to exclude events from in the final recording.</param>
 /// <returns></returns>
 public SubjectRecording Save(float startTime, float endTime, IEnumerable <Vector2> pauseSlices)
 {
     return(new SubjectRecording(
                instanceId,
                name,
                metadata,
                InterpolateFilterAndShift(capturedPositions, startTime, endTime, pauseSlices),
                InterpolateFilterAndShift(capturedRotations, startTime, endTime, pauseSlices),
                Squash(capturedLifeCycleEvents, startTime, endTime, pauseSlices),
                CaptureUtil.FilterAndShift(capturedCustomActorEvents, startTime, endTime, pauseSlices)));
 }
Exemplo n.º 3
0
        /// <summary>
        /// Stops the recorder and builds a recording for playback. Once a recorder is finished it is free to start making a whole new recording.
        /// </summary>
        /// <returns>A recording containing everything the recorder captured while not paused.</returns>
        /// <exception cref="System.InvalidOperationException">Thrown when the recorder is stopped.</exception>
        public Recording Finish()
        {
            if (CurrentlyStopped())
            {
                throw new System.InvalidOperationException("Not recording anything! Nothing to build!");
            }

            if (CurrentlyPaused())
            {
                Resume();
            }
            currentState = RecordingState.Stopped;
            var recordings = new SubjectRecording[subjectsToRecord.Count];

            for (int i = 0; i < recordings.Length; i++)
            {
                recordings[i] = subjectsToRecord[i].Save(timeStarted, Time.time, pauseSlices);
            }
            return(Recording.CreateInstance(recordings, CaptureUtil.FilterAndShift(customEvents, timeStarted, Time.time, pauseSlices), metadata));
        }