Setting up Camera Functionality

The next panel we are going to work on that has some special functionality is our photo panel. Luckily, there is a great open source plugin called Native Camera available on the Unity asset store for free that handles all of the coding needed for this:

Once we have it within our asset library, we will want to add it to our project:

Once we have added it to the library, we can then take a look at the plugins folder that was added and go through the read me for instructions on how to get it working, and a link to the github for further instructions:

Within the readme, we have the code that we will need to implement into our script:

With how we plan on using this code for the picture we are taking, we don’t need to add the whole TakePicture void:

What we have done is just kept the first little bit of the code that is supplied to us, and we switched over the rest to have the texture replace that of the raw image that we have waiting to be updated. As the order of the raw image will overlap that of the picture, we don’t have to worry about deactivating our image placeholder. From here, we will also have the image be moved over to our building case file in the UIManager. As for the option to open up the camera, we are simply going to add a button to our static image for the user to be able to click on it to open up their camera:

With this all set up, we are now able to take a picture within our app. The final part is just added the logic to allow the next button to be pressed when a picture has been added and we can look towards the next part of the project.




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

The Covid-19 Online Semester Log

Python vs R

Unity or User Error

Bringing Fibers to TruffleRuby

Implement RecyclerView in my way (a little bit advance)


SOLID Principles: Liskov Substitution Principle (LSP)

Creating Git Repository From Scratch

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jordan Evans

Jordan Evans

More from Medium

Connecting our Information and Working with Maps

Creating MineField In Unity (Part 1)

How to Remove a Large File from Commit History in Git?

Cross-Platform Input Controller!