31 lines
867 B
C#
31 lines
867 B
C#
|
using System.Collections;
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.UI;
|
||
|
|
||
|
public class CameraManager : MonoBehaviour
|
||
|
{
|
||
|
// Start is called before the first frame update
|
||
|
IEnumerable Start()
|
||
|
{
|
||
|
yield return Application.RequestUserAuthorization(UserAuthorization.WebCam);
|
||
|
if (Application.HasUserAuthorization(UserAuthorization.WebCam))
|
||
|
{
|
||
|
Debug.Log("webcam found");
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
Debug.Log("webcam not found");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Update is called once per frame
|
||
|
void Update()
|
||
|
{
|
||
|
WebCamDevice[] devices = WebCamTexture.devices;
|
||
|
var webcamTexture = new WebCamTexture(devices[0].name);
|
||
|
gameObject.GetComponent<RawImage>().texture = webcamTexture;
|
||
|
gameObject.GetComponent<RawImage>().material.mainTexture = webcamTexture;
|
||
|
webcamTexture.Play();
|
||
|
}
|
||
|
}
|