josh
josh

Reputation: 1689

Open device camera for iPhone and Android in Unity3d

I am working an application in which i need to open device camera in full view and i am making this app for both iOS and Android. So can any one tell me that how can i open full screen device camera in Unity for all devices Android and iPhone. This will be great help for me. Thanks in advance.

Upvotes: 6

Views: 28910

Answers (4)

Habibur Rahman Ovie
Habibur Rahman Ovie

Reputation: 281

There is a great plugin named Android native Camera for open device camera and save the video or image inside the device. Currently, it works only android.

Upvotes: 0

Calvin
Calvin

Reputation: 4195

If you mean you want to use the camera to take and save photographs, I'd recommend Prime31's iOS and Android plugins. Unfortunately the Etcetera plugin is us$65 per platform, but I've used them both and they work great.

http://u3d.as/content/prime31/i-os-etcetera-plugin/2CU

http://u3d.as/content/prime31/android-etcetera-plugin/2CY

If you just want to show the camera's live output inside of your app's scene, you can create a plane and use a WebCamTexture to display the camera's live video output.

http://docs.unity3d.com/Documentation/ScriptReference/WebCamTexture.html

Upvotes: 6

Chris
Chris

Reputation: 508

There is a toolkit available to open the device camera in unity for iOS and Android called CameraCaptureKit - (https://www.assetstore.unity3d.com/en/#!/content/56673)

All the source is available and it has a plain and and simple plug'n'play demo as with Unity UI - it solves some of the obstacles involved with taking still images using the camera on your device.

Since the WebCamTexture is a generic solution to taking still images it doesn't enable sharpening of the images, the quality as well is more low-res on iOS since it uses a configuration for capturing real time video.

If you want to turn on flash / torch there you can do that with the toolkit.

Upvotes: 1

swiftBoy
swiftBoy

Reputation: 35783

After some more digging on Google and Official docs. I got solution which I am going to share with you , It help someone .. someday..

1.Create New Project.

2.Select Main Camera in GameObject and change Transform via Inspector

Position X= -90 Y=785 Z=0 Rotation X=90 Y=90 Z=0 Scale X=1 Y=1 Z=1

enter image description here

3.Now go to GameObject — > Create Other — > Plane.

4.Select Main Camera in GameObject and

4.1 change Transform via Inspector

Position X=0 Y=0 Z=0 Rotation X=0 Y=0 Z=0 Scale X=100 Y=100 Z=100 enter image description here

4.2 change Tag=Player

Now create a c# script with name “CameraController” and replace the code with below one

using UnityEngine;
using System.Collections;

public class CameraController : MonoBehaviour
{
        public WebCamTexture mCamera = null;
        public GameObject plane;

        // Use this for initialization
        void Start ()
        {
                Debug.Log ("Script has been started");
                plane = GameObject.FindWithTag ("Player");

                mCamera = new WebCamTexture ();
                plane.renderer.material.mainTexture = mCamera;
                mCamera.Play ();

        }

        // Update is called once per frame
        void Update ()
        {

        }
}

5.Finally save and Drag this Script file onto “Plane” GameObject

Note - you may see preview rotated in Unity Game view but on RealDevice it works well. tested on iPhone5 and Android - Nexus 5.

Here is the snap shot how it comes if you change rotation angle to 180: enter image description here

Upvotes: 18

Related Questions