PTN
PTN

Reputation: 1692

Cannot use camera on iPhone when run with Unity

I am running a very simple script to access the camera. It works with the webcam on my laptop but it gives me a white screen when I run it on my iPhone

public class CameraController : MonoBehaviour {

    public WebCamTexture mCamera = null;
    public GameObject plane;

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

        mCamera = new WebCamTexture ();
        plane.GetComponent<Renderer>().material.mainTexture = mCamera;
        mCamera.Play ();

    }

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

When I build and run, Unity fires up XCode, where I also update info.plist so it asks for permission to access the camera

<key>NSCameraUsageDescription</key>
<string>$(PRODUCT_NAME) camera use</string>

Upvotes: 0

Views: 1953

Answers (1)

Related Questions