using UnityEngine; using UnityEngine.UI; public class CameraManager : MonoBehaviour { public WebCamTexture webCamTexture; public Button freezeButton; public Button resumeButton; // Start is called before the first frame update void Start() { webCamTexture = new WebCamTexture(); WebcamResume(); } // Update is called once per frame void Update() { gameObject.GetComponent().texture = webCamTexture; gameObject.GetComponent().material.mainTexture = webCamTexture; } public void WebcamResume() { webCamTexture.Play(); freezeButton.gameObject.SetActive(true); resumeButton.gameObject.SetActive(false); } public void WebcamChange() { foreach (WebCamDevice webCamDevice in WebCamTexture.devices) { if (webCamTexture.deviceName != webCamDevice.name) { webCamTexture = new WebCamTexture(webCamDevice.name); WebcamResume(); } } } public void WebcamStop() { webCamTexture.Stop(); freezeButton.gameObject.SetActive(false); resumeButton.gameObject.SetActive(true); } }