PermissionRequest.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.Android;
  5. public class PermissionRequest : MonoBehaviour
  6. {
  7. public bool Camera = true;
  8. public bool ExternalStorageRead = true;
  9. public bool ExternalStorageWrite = true;
  10. public bool Microphone = false;
  11. public bool FineLocation = false;
  12. public bool CoarseLocation = false;
  13. void Awake() {
  14. List<string> permissionList = new List<string>();
  15. if(Camera) {
  16. permissionList.Add(Permission.Camera);
  17. }
  18. if(ExternalStorageRead) {
  19. permissionList.Add(Permission.ExternalStorageRead);
  20. }
  21. if(ExternalStorageWrite) {
  22. permissionList.Add(Permission.ExternalStorageWrite);
  23. }
  24. if(Microphone) {
  25. permissionList.Add(Permission.Microphone);
  26. }
  27. if(FineLocation) {
  28. permissionList.Add(Permission.FineLocation);
  29. }
  30. if(CoarseLocation) {
  31. permissionList.Add(Permission.CoarseLocation);
  32. }
  33. if(permissionList.Count > 0) {
  34. AndroidPermission.getInstant.GetPermission(permissionList);
  35. }
  36. }
  37. }