Last active
February 21, 2020 15:19
-
-
Save federico121/7c2c1437adf16463d27d43dc59bf3c9a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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