Skip to content

Instantly share code, notes, and snippets.

@federico121
Last active February 21, 2020 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save federico121/7c2c1437adf16463d27d43dc59bf3c9a to your computer and use it in GitHub Desktop.
Save federico121/7c2c1437adf16463d27d43dc59bf3c9a to your computer and use it in GitHub Desktop.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WebCamDirect : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
Debug.Log("DisplayWebcam Initialize");
// Transform values of the plane to get you started:
// position 0 0 200
// rotation 90 180 0
// scale 80 1 40
var devices = WebCamTexture.devices;
var backCamName = "";
if (devices.Length > 0) backCamName = devices[0].name;
for (int i = 0; i < devices.Length; i++)
{
Debug.Log("Device:" + devices[i].name + "IS FRONT FACING:" + devices[i].isFrontFacing);
if (!devices[i].isFrontFacing)
{
backCamName = devices[i].name;
}
}
var CameraTexture = new WebCamTexture(backCamName, 10000, 10000, 30);
CameraTexture.Play();
var renderer = GetComponent<Renderer>();
renderer.material.mainTexture = CameraTexture;
}
// Update is called once per frame
void Update()
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment