Snaparazzi/Assets/Scripts/CameraManager.cs
2024-01-27 12:31:58 +01:00

23 lines
579 B
C#

using UnityEngine;
using UnityEngine.UI;
public class CameraManager : MonoBehaviour
{
public WebCamTexture webCamTexture;
// Start is called before the first frame update
void Start()
{
WebCamDevice[] devices = WebCamTexture.devices;
webCamTexture = new WebCamTexture(devices[0].name);
webCamTexture.Play();
}
// Update is called once per frame
void Update()
{
gameObject.GetComponent<RawImage>().texture = webCamTexture;
gameObject.GetComponent<RawImage>().material.mainTexture = webCamTexture;
}
}