Tanoda
RecordingMixerBehaviour.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.Playables;
10
11namespace Leap.Unity.Recording {
12
13 public class RecordingMixerBehaviour : PlayableBehaviour {
14
15 private Frame _frame;
16
17 public override void OnGraphStart(Playable playable) {
18 base.OnGraphStart(playable);
19
20 _frame = new Frame();
21 }
22
23 // NOTE: This function is called at runtime and edit time. Keep that in mind when setting the values of properties.
24 public override void ProcessFrame(Playable playable, FrameData info, object playerData) {
25 LeapPlayableProvider provider = playerData as LeapPlayableProvider;
26
27 if (!provider)
28 return;
29
30 int inputCount = playable.GetInputCount();
31
32 for (int i = 0; i < inputCount; i++) {
33 float inputWeight = playable.GetInputWeight(i);
34 var inputPlayable = (ScriptPlayable<RecordingBehaviour>)playable.GetInput(i);
35 var input = inputPlayable.GetBehaviour();
36
37 if (inputWeight > 0 && input.recording != null) {
38 if (input.recording.Sample((float)inputPlayable.GetTime(), _frame, clampTimeToValid: true)) {
39 provider.SetCurrentFrame(_frame);
40 break;
41 }
42 }
43 }
44 }
45 }
46}
The Frame class represents a set of hand and finger tracking data detected in a single frame.
Definition: Frame.cs:24
override void ProcessFrame(Playable playable, FrameData info, object playerData)