How to set up camera functionality in Unity

Let’s go over how to make it possible to take a picture with the mobile camera in Unity.

First, download and import the plugin Native Camera from the asset store:

All the information needed to use the plugin can be found here https://github.com/yasirkula/UnityNativeCamera. For the set up in this article I will use part of the code on the bottom of the Github page:

Create a script with a suitable name and attach to a game object in the scene:

Open up the script and add a public function which will in turn call the TakePicture function:

Add the TakePicture function to the script and in this article I added the photo taken as a texture on a RawImage UI object:

Lastly, add the public function as an OnClick event on the UI Button:

Good luck!