1
votes

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 () {

    }
}
1

1 Answers

0
votes

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.