using System.Collections;
using TMPro;
using UnityEngine;
///
/// Authorize and check for available webcam(s)
///
public class BootScreen : MonoBehaviour
{
///
/// UI Reference to the text object to display an error message
///
public TMP_Text errorText;
///
/// Reference to the list that holds all user avatars
///
public UserAvatarList sprites;
///
/// Request authorization and check whether at least 1 webcam is available
///
IEnumerator Start()
{
UserList.AVATARS = sprites.avatars;
PersistentDataController.GetInstance().Load();
yield return Application.RequestUserAuthorization(UserAuthorization.WebCam);
if (Application.HasUserAuthorization(UserAuthorization.WebCam))
{
if (0 < WebCamTexture.devices.Length)
{
WebCamTexture webcamTexture = new WebCamTexture();
webcamTexture.deviceName = WebCamTexture.devices[0].name;
webcamTexture.Play();
yield return new WaitForSeconds(0.1f); // Wait a little for the webcam to start
if (webcamTexture.isPlaying)
{
webcamTexture.Stop();
SystemController.GetInstance().SwapScene("Common/Scenes/MainMenuScreen");
}
else
{
errorText.text = "Zorg ervoor dat je webcam niet in gebruik is door een andere applicatie!";
}
}
else
{
errorText.text = "Zorg ervoor dat je webcam correct is aangesloten!";
}
}
else
{
errorText.text = "Zorg ervoor dat deze applicatie toegang heeft tot je webcam!";
}
}
}