using System.Collections;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
///
/// Authorize and check for available webcam(s)
///
public class WebcamAuthorization : MonoBehaviour
{
///
/// UI Reference to the text object to display an error message
///
public TMP_Text errorText;
///
/// Request authorization and check whether at least 1 webcam is available
///
/// IEnumerator object
IEnumerator Start()
{
yield return Application.RequestUserAuthorization(UserAuthorization.WebCam);
if (Application.HasUserAuthorization(UserAuthorization.WebCam))
{
if (0 < WebCamTexture.devices.Length)
{
SceneManager.LoadScene("Common/Scenes/StartScreen");
}
else
{
errorText.text = "Zorg ervoor dat je webcam correct is aangesloten!";
}
}
else
{
errorText.text = "Zorg ervoor dat deze applicatie toegang heeft tot je webcam!";
}
}
}