NatCorder
Search…
Getting Started
Up and Running in No Time
To begin, import the API from the Unity Asset Store.
Once the API is imported, you can begin to write recording code. Let's create a recorder to record a WebCamTexture.
RecordWebCam.cs
1
using UnityEngine;
2
using System.Threading.Tasks;
3
using NatSuite.Recorders;
4
5
public class RecordWebCam : MonoBehaviour {
6
7
async void Start () {
8
// Start the webcam
9
var cameraTexture = new WebCamTexture();
10
cameraTexture.Play();
11
12
// Wait for user to smile :)
13
await Task.Delay(2000);
14
15
// Create a recorder
16
var recorder = new GIFRecorder(
17
cameraTexture.width, // image width
18
cameraTexture.height, // image height
19
0.1f // frame duration in seconds
20
);
21
22
// Record 20 frames
23
for (var i = 0; i < 20; i++) {
24
// Commit frame
25
recorder.CommitFrame(cameraTexture.GetPixels32());
26
// Wait a bit before next commit
27
await Task.Delay(150);
28
}
29
30
// All done
31
var path = await recorder.FinishWriting();
32
}
33
}
Copied!
Add this component to any game object in your scene and enter Play mode. After about 5 seconds, you should find a .gif file sitting in your project folder!
This is the general pattern you will follow when working with NatCorder. Before going into more details, look through the minimum requirements for developing with and deploying NatCorder.
Last modified 1yr ago
Copy link