NatCam Tutorial Series 3: Photos
Hi guys. Welcome to part 3 of the NatCam Tutorial Series. In this part, we will be discussing photo capture with NatCam. First, make sure you have gone over part 1 and part 2.
Capturing a Photo
Photo capture is one of the most essential features of NatCam. NatCam provides this functionality through the CapturePhoto method:
Let’s walk through a simple example utilizing photo capture.
PhotoCam Example
Starting with a blank Unity project, import NatCam. Now let us create a RawImage that covers the whole screen; I’ll call mine ‘Preview’

Now, let us create a PhotoCam script. We will check for a double tap on the screen, and if we get one, we will capture a photo.
Let’s plug it all in in the Editor.

Memory Management and Best Practices
I would like to bring the very important issue of memory management to your attention. It is quite often overlooked, but Texture objects are not CLR objects, as a result, garbage collection will not free their resources. If you find yourself running out of memory after taking a few pictures, it is because you must free each picture from memory when you are done with it. To do so, simply call:
That’s it for this tutorial. In the next tutorial, I will discuss accessing the preview data in realtime with NatCam. See you next time!
— Lanre Olokoba.
NatCam is a cross-platform camera API for the Unity Engine. Get NatCam here: NatCam.
