forked from handzlikchris/Unity.QuestRemoteHandTracking
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HandsDataRecording.cs
92 lines (75 loc) · 3.12 KB
/
HandsDataRecording.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
using System;
using System.Collections.Generic;
using Assets.RemoteHandsTracking.Data;
using Assets.RemoteHandsTracking.Utilities;
using UnityEngine;
namespace Assets.RemoteHandsTracking
{
public class InitHandData
{
public SkeletonData LeftHandSkeletonData { get; set; }
public SkeletonData RightHandSkeletonData { get; set; }
public MeshData RightHandMeshData { get; set; }
public MeshData LeftHandMeshData { get; set; }
public bool AreAllAssigned => LeftHandSkeletonData != null && RightHandSkeletonData != null &&
LeftHandMeshData != null && RightHandMeshData != null;
public InitHandData(SkeletonData leftHandSkeletonData, SkeletonData rightHandSkeletonData, MeshData rightHandMeshData, MeshData leftHandMeshData)
{
LeftHandSkeletonData = leftHandSkeletonData;
RightHandSkeletonData = rightHandSkeletonData;
RightHandMeshData = rightHandMeshData;
LeftHandMeshData = leftHandMeshData;
}
[Obsolete("Required for serialization")]
public InitHandData()
{
}
}
public class PersistedHandsDataRecording
{
public string Name { get; set; }
public List<HandsDataRecordedFrame> HandsDataRecordedFrames { get; set; }
public InitHandData InitHandData { get; set; }
public PersistedHandsDataRecording(string name, List<HandsDataRecordedFrame> handsDataRecordedFrames, InitHandData initHandData)
{
Name = name;
HandsDataRecordedFrames = handsDataRecordedFrames;
InitHandData = initHandData;
}
[Obsolete("Required for serialization")]
public PersistedHandsDataRecording()
{
}
}
public class HandsDataRecording : MonoBehaviour
{
public List<HandsDataRecordedFrame> HandsDataRecordedFrames { get; private set; }
public string RecordingName { get; private set; }
private Action<HandsDataRecording> _delete;
private Action<HandsDataRecording> _play;
public InitHandData InitHandData { get; private set; }
public static HandsDataRecording Create(Transform parentContainer, string recordingName, List<HandsDataRecordedFrame> handsDataRecordedFrames,
InitHandData initHandData, Action<HandsDataRecording> delete, Action<HandsDataRecording> play)
{
var recording = new GameObject(recordingName);
recording.transform.parent = parentContainer;
var handsDataRecording = recording.AddComponent<HandsDataRecording>();
handsDataRecording.HandsDataRecordedFrames = handsDataRecordedFrames;
handsDataRecording._delete = delete;
handsDataRecording._play = play;
handsDataRecording.InitHandData = initHandData;
handsDataRecording.RecordingName = recordingName;
return handsDataRecording;
}
[EditorButton]
public void Play()
{
_play(this);
}
[EditorButton]
public void Delete()
{
_delete(this);
}
}
}