言語: 日本語
  • C#
  • JS
  • Boo

スクリプト言語

お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。

Application.RequestUserAuthorization

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public static function RequestUserAuthorization(mode: UserAuthorization): AsyncOperation;
public static AsyncOperation RequestUserAuthorization(UserAuthorization mode);
public static def RequestUserAuthorization(mode as UserAuthorization) as AsyncOperation

Description

Web Player でウェブカメラやマイクを使用する際にユーザーに許可を求めます。

セキュリティ上の理由(WebPlayerでユーザーを見張るような実装を避けるため)で WebPlayerでは明示的にこの機能をユーザーの手で許可する必要があります。 これを行うにはApplication.RequestUserAuthorizationを呼び出すことが必要で、ユーザーにダイアログボックスを表示します。 そしてこれらの機能が使えるようになるまでの操作が完了するまで待ちます。 操作結果を得るために Application.HasUserAuthorization を使用します。

	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 ExampleClass : 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 ExampleClass(MonoBehaviour):

	def Start() as IEnumerator:
		yield Application.RequestUserAuthorization((UserAuthorization.WebCam | UserAuthorization.Microphone))
		if Application.HasUserAuthorization((UserAuthorization.WebCam | UserAuthorization.Microphone)):
			pass
		else:
			pass