-
Notifications
You must be signed in to change notification settings - Fork 0
/
natCorderRecord.cs
124 lines (95 loc) · 2.54 KB
/
natCorderRecord.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// Custom Action by DumbGameDev
// www.dumbgamedev.com
using UnityEngine;
using NatCorderU;
using NatCorderU.Core;
using NatCorderU.Extensions;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory("Nat Corder")]
[Tooltip("Start recording using Nat Corder")]
public class natCorderRecord : FsmStateAction
{
[RequiredField]
[Title ("Camera")]
[Tooltip("Camera to use for recording.")]
public FsmGameObject goCamera;
[ActionSection ("Output")]
[UIHint(UIHint.Variable)]
[Tooltip("Save the recording path to a variable for playback later.")]
public FsmString recordingPath;
[ActionSection ("Options")]
[Tooltip("Optionally choose the game object with the audio listener. If none is chosen, no audio will be recorded")]
public FsmGameObject audioListener;
[Tooltip("Enable output to debug log for testing purposes.")]
public FsmBool enableDebug;
private Camera natCamera;
private AudioListener _audioListener;
public override void Reset()
{
goCamera = null;
recordingPath = null;
audioListener = new FsmGameObject {UseVariable = true};
_audioListener = null;
natCamera = null;
}
public override void OnEnter()
{
// get camera from playmaker FSM
natCamera = goCamera.Value.GetComponent<Camera>();
NatCorder.Verbose = true;
if(!audioListener.IsNone)
{
_audioListener = audioListener.Value.GetComponent<AudioListener>();
}
if(natCamera != null)
{
if(enableDebug.Value)
{
Debug.Log("Start Camera Methods");
}
// camera found, do record
doRecord();
}
else
{
if(enableDebug.Value)
{
Debug.Log("No Camera Found");
}
}
Finish();
}
void doRecord()
{
// if not already recording, start recording
if (!Replay.IsRecording)
{
// debug log
if(enableDebug.Value)
{
Debug.Log("Recording Started");
}
// record without sound
if(audioListener.IsNone)
{
Replay.StartRecording(natCamera, Configuration.Default, savePath);
}
// record with sound
if(!audioListener.IsNone)
{
Replay.StartRecording(natCamera, Configuration.Default, savePath, _audioListener);
}
}
}
void savePath (string path) {
// save path for playmaker
recordingPath.Value = path;
// debug log
if(enableDebug.Value)
{
Debug.Log("Saved recording to: "+path);
}
}
}
}