1

I'm experimenting to have device camera (Pixel phone) real-time video show in Daydream app built by Unity. In Unity I tried WebCamTexture, and when test run in Unity on a PC, WebCamTexture captures the webcam feed, but when I build the app to Daydream /Cardboard, there is no camera feed. However, I did put a canvas / text to print out if any camera is detected, and if so, the name of the camera. In Daydream app when running, 2 cameras are detected (Camera 0 , Camera 1), but no image shown. Does any one have ideas/ suggestions how to solve this? The following is the code I wrote in C# and attached it to a Unity Plane/ Quad, and also referenced a Canvas Text.

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class tWebCam : MonoBehaviour
{
    public Text textPanel;
    WebCamTexture mCamera = null;

    public GameObject camPlane;
    // Use this for initialization
    void Start ()
    {
        WebCamDevice[] devices = WebCamTexture.devices;

        //camPlane = GameObject.FindWithTag("Player");

        if (devices.Length > 0)
        {
            mCamera = new WebCamTexture(devices[devices.Length-1].name, 1920, 1920, 30);
            camPlane.GetComponent<Renderer>().material.mainTexture = mCamera;

            mCamera.deviceName = devices[devices.Length - 1].name;
            Debug.Log(devices.Length);
            Debug.Log(mCamera.deviceName);
            mCamera.Play();
            textPanel.text = "# of devices: " + devices.Length.ToString() + "; Device 1: " + mCamera.deviceName;
        }
        else
        {
            textPanel.text = "No device detected...";
        }


    }

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

    }
}
mariopinto
  • 33
  • 7

1 Answers1

0

If I understand your question, the camera won't work because the phone is inside either the Cardboard or Daydream headsets and is thus physically obstructed.

  • Thanks for the answer Justin. The physical occlusion of the cardboard or daydream headset can be modified, so that is not my main concern. What tI am trying to figure out is whether it is possible to access the device camera. On a side note, I noticed that for project tango, there is an experiment example to combine Tango and Cardboard. Hence can work as insideout tracking; neverthrless, it only works on Tango ready device. – thomas huang Feb 17 '17 at 03:40