Unity アプリケーションのサンドボックス外でデバイスの機能やデータにアクセスする権限 (許可) の取得には、2 つの段階があります。
一部の権限については、ビルド時の Android アプリマニフェストのエントリーと実行時の権限リクエストの両方が、Unity によって自動的に処理されます。詳細は Unity によって処理される権限 を参照してください。
Android アプリケーションは、Android アプリマニフェストで宣言したデバイス機能やデータに関してのみ、ユーザーに権限をリクエストすることができます。これは、Android の権限処理の、ビルド時の段階です。権限の宣言方法については アプリケーションの権限の宣言 を参照してください。
ノート: プラグインがその Android アプリマニフェストで権限を宣言している場合、Gradle が、Gradle のマージの段階で、最終的な Android アプリマニフェストにその権限を自動的に追加します。
実行時の権限は、アプリケーション実行中のどの時点でもリクエスト可能です。制限付きデータやデバイス機能へのアクセス権限のリクエストは、アプリケーションがそのデータや機能を必要とする状況が初めて発生したタイミングで行うのが最も適切です。また、アプリケーションがそのデータや機能を必要とする理由を説明するメッセージを、リクエストの送信前にユーザーに対して表示する必要があります。ユーザーが困惑しないようにコンテキストを提供することで、権限のリクエストがなるべく拒否されないようにすることが重要です。
実行時に権限をリクエストする方法については、実行時の権限のリクエスト を参照してください。
重要: Android アプリマニフェストが宣言していない権限をユーザーにリクエストしようとした場合、デバイスに権限ダイアログが表示されません。
Unity は、Player 設定 と、アプリケーションの使用している Unity API に基づいて、必要な権限の一部を Android アプリマニフェストに自動的に追加し、実行時に権限リクエストを送信します。これは、アプリケーションの使用するプラグインに関しても同様です。
Unity が実行時に権限リクエストを自動送信しないようにするには、Android アプリマニフェストに unityplayer.SkipPermissionsDialog
を追加します。これは、アプリケーションが各権限を必要とする理由についての情報を、ユーザーが権限リクエストを見る前に提供したい場合に役立ちます。この場合、権限リクエストを手動で送信する必要があります。詳細は 実行時の権限のリクエスト を参照してください。
Unity がどの権限を自動的に処理するかに関しては、以下のリストを参照してください。
VIBRATE
権限を追加します。ACCESS_NETWORK_STATE
権限を追加します。ACCESS_FINE_LOCATION
権限を追加し、アプリケーションが初めて位置情報を使用する時にユーザーにこの権限をリクエストします。CAMERA
権限を追加し、アプリケーションが初めて WebCamTexture
を使用する時にユーザーにこの権限をリクエストします。RECORD_AUDIO
権限を追加し、アプリケーションが初めて Microphone
を使用する時にユーザーにこの権限をリクエストします。Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.