Request authorization to use the webcam or microphone in the Web Player.
function Start() { // Request permission to use both webcam and microphone. yield Application.RequestUserAuthorization (UserAuthorization.WebCam | UserAuthorization.Microphone); if (Application.HasUserAuthorization(UserAuthorization.WebCam | UserAuthorization.Microphone)) { // we got permission. Set up webcam and microphone here. } else { // no permission. Show error here. } }
using UnityEngine; using System.Collections; public class Example : MonoBehaviour { IEnumerator Start() { yield return Application.RequestUserAuthorization(UserAuthorization.WebCam | UserAuthorization.Microphone); if (Application.HasUserAuthorization(UserAuthorization.WebCam | UserAuthorization.Microphone)) { } else { } } }
import UnityEngine import System.Collections public class Example(MonoBehaviour): def Start() as IEnumerator: yield Application.RequestUserAuthorization((UserAuthorization.WebCam | UserAuthorization.Microphone)) if Application.HasUserAuthorization((UserAuthorization.WebCam | UserAuthorization.Microphone)): pass else: pass