Version: 2020.3

Application.RequestUserAuthorization

매뉴얼로 전환
public static AsyncOperation RequestUserAuthorization (UserAuthorization mode);

설명

Request authorization to use the webcam or microphone on iOS.

The call of Application.RequestUserAuthorization requests permission for microphone and camera. The application shows a dialog box to the user and waits for operation to complete before being able to use these features.

Note: Use Application.HasUserAuthorization to query the result of the operation.

using UnityEngine;
using UnityEngine.iOS;
using System.Collections;

// Show WebCams and Microphones on an iPhone/iPad. // Make sure NSCameraUsageDescription and NSMicrophoneUsageDescription // are in the Info.plist.

public class ExampleClass : MonoBehaviour { IEnumerator Start() { findWebCams();

yield return Application.RequestUserAuthorization(UserAuthorization.WebCam); if (Application.HasUserAuthorization(UserAuthorization.WebCam)) { Debug.Log("webcam found"); } else { Debug.Log("webcam not found"); }

findMicrophones();

yield return Application.RequestUserAuthorization(UserAuthorization.Microphone); if (Application.HasUserAuthorization(UserAuthorization.Microphone)) { Debug.Log("Microphone found"); } else { Debug.Log("Microphone not found"); } }

void findWebCams() { foreach (var device in WebCamTexture.devices) { Debug.Log("Name: " + device.name); } }

void findMicrophones() { foreach (var device in Microphone.devices) { Debug.Log("Name: " + device); } } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961