Android Ultimate Plugin Tutorial part 12 – Camera and Share

Hello Every one , i know that you wanted to know on how to use the Camera feature on Android Ultimate Plugin , and today is that day so let’s get started.

First make sure that you have an Android Manifest File  in “Assets/Plugins/Android” and you added this permissions

After added that permissions on your Android Manifest File we can start coding now.

First get the instance of  Custom Camera Plugin

Set Debug to 0 because i don’t want to see any Debug Toast Messages it’s annoying.

Then we initialized the Camera Plugin and pass the folder name where we wanted our image to be save.

Note:

folderName will be the name of folder on the actual device

imageFilaName will be the name of Image that you take

ImagePath is actual directory path where you will save the image

useBackCamera is to know if you want to use front or back camera if front just pass false if back pass true

After Initialization we need to setup callback listener for our Camera Plugin and we need to pass our methods onCaptureImageComplete, onCaptureImageComplete and onCaptureImageFail.

 

after we setup our Camera Plugin  we can now start taking picture using our Camera on our Android Device. we can do this by calling this method

After taking picture  we will received an events

onCaptureImageComplete – if successful

an Image paths on where our picture has been saved. we can now use this to load the texture by calling Utils.LoadTexture and pass image path on it

 

onCaptureImageFail – if failed

onCaptureImageCancel – if camera is cancel

and then we can share it just by passing Image path on Share Image method of SharePlugin together with “Share Subject Title” and “Share message”

And this is the exact code that we use on our  Custom Camera Plugin  and Share demo

Note:  you need to drag Text and RawImage UI  on this code inspector to make it run and also you need Button UI to access the open camera method.

I think we are done,  you can now test this code on your Android Device and see what will happen.

I Hope this tutorial some how helps you on dealing with  Custom Camera Plugin

For more Information

http://www.gigadrillgames.com/android-ultimate-plugin/

For more Tutorials

http://www.gigadrillgames.com/2015/07/26/list-of-tutorials-for-android-ultimate-plugin/

For Questions or Comments or any Feed back just email us at gigadrillgames@gmail.com

 

Leave a Reply

Your email address will not be published. Required fields are marked *

*