Tanoda
MethodRecordingPlayable.cs
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) Ultraleap, Inc. 2011-2020. *
3 * *
4 * Use subject to the terms of the Apache License 2.0 available at *
5 * http://www.apache.org/licenses/LICENSE-2.0, or another agreement *
6 * between Ultraleap and you, your company or other organization. *
7 ******************************************************************************/
8
9using UnityEngine;
10using UnityEngine.Playables;
11
12namespace Leap.Unity.Recording {
13
14 public class MethodRecordingPlayable : PlayableBehaviour {
15 private double _prevTime = double.NaN;
16
17 public bool invokeAtEditTime;
18
19 public override void ProcessFrame(Playable playable, FrameData info, object playerData) {
20 if (!Application.isPlaying && !invokeAtEditTime) {
21 return;
22 }
23
24 var recording = playerData as MethodRecording;
25 if (recording == null) {
26 return;
27 }
28
29 if (recording.mode != MethodRecording.Mode.Playback) {
30 recording.EnterPlaybackMode();
31 }
32
33 float prevTime = (float)playable.GetPreviousTime();
34 float nowTime = (float)playable.GetTime();
35 bool didSeek = _prevTime != playable.GetPreviousTime() || nowTime < prevTime;
36
37 if (!didSeek) {
38 recording.SweepTime(prevTime, nowTime);
39 }
40
41 _prevTime = playable.GetTime();
42 }
43 }
44}
override void ProcessFrame(Playable playable, FrameData info, object playerData)