Snaparazzi/Assets/Scripts/CameraManager.cs

23 lines
579 B
C#
Raw Normal View History

2024-01-27 10:26:34 +00:00
using UnityEngine;
using UnityEngine.UI;
public class CameraManager : MonoBehaviour
{
2024-01-27 11:31:58 +00:00
public WebCamTexture webCamTexture;
2024-01-27 10:26:34 +00:00
// Start is called before the first frame update
2024-01-27 11:31:58 +00:00
void Start()
2024-01-27 10:26:34 +00:00
{
2024-01-27 11:31:58 +00:00
WebCamDevice[] devices = WebCamTexture.devices;
webCamTexture = new WebCamTexture(devices[0].name);
webCamTexture.Play();
2024-01-27 10:26:34 +00:00
}
// Update is called once per frame
void Update()
{
2024-01-27 11:31:58 +00:00
gameObject.GetComponent<RawImage>().texture = webCamTexture;
gameObject.GetComponent<RawImage>().material.mainTexture = webCamTexture;
2024-01-27 10:26:34 +00:00
}
}