Exemplo n.º 1
0
    public override void Awake()
    {
        base.Awake();

        //Find and fetch a reference to the Main Camera in the scene
        _mainCamera = GameObject.FindGameObjectWithTag("MainCamera");
        //Check if we found a reference
        if (_mainCamera != null)
        {
            //Disable the Main Camera, we are using the MAXST AR Camera instead
            _mainCamera.SetActive(false);
        }

        AndroidRuntimePermissions.Permission[] result = AndroidRuntimePermissions.RequestPermissions("android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.CAMERA");
        if (result[0] == AndroidRuntimePermissions.Permission.Granted && result[1] == AndroidRuntimePermissions.Permission.Granted)
        {
            Debug.Log("We have all the permissions!");
        }
        else
        {
            Debug.Log("Some permission(s) are not granted...");
        }

        cameraBackgroundBehaviour = FindObjectOfType <CameraBackgroundBehaviour>();
        if (cameraBackgroundBehaviour == null)
        {
            Debug.LogError("Can't find CameraBackgroundBehaviour.");
            return;
        }
    }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (isDialogPermission)
        {
            isDialogPermission = false;

            Debug.Log("KAUEL: Vamos a la siguiente escena");
            LoadA("Scene01");
        }

        if (!isStartPermissions)
        {
            isStartPermissions = true;
            AndroidRuntimePermissions.Permission[] result = AndroidRuntimePermissions.RequestPermissions("android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.CAMERA");
            if (result[0] == AndroidRuntimePermissions.Permission.Granted && result[1] == AndroidRuntimePermissions.Permission.Granted)
            {
                isDialogPermission = true;
                Debug.Log("KAUEL: permission(s) are granted by dialog");
                CargarEscena("Scene01");
            }
            else
            {
                Debug.Log("KAUEL: Some permission(s) are not granted, reaload same scene");
                LoadA("ScenePreload");
            }
        }
    }
Exemplo n.º 3
0
 private AndroidRuntimePermissions.Permission[] requestPermissions()
 {
     return(AndroidRuntimePermissions.RequestPermissions(new string[] {
         ANDROID_PERMISSION_PREFIX + AndroidPermission.ACCESS_FINE_LOCATION,
         ANDROID_PERMISSION_PREFIX + AndroidPermission.CAMERA
     }));
 }
Exemplo n.º 4
0
    void Update()
    {
#if UNITY_ANDROID && !UNITY_EDITOR
        if (!isPermission)
        {
            //AndroidRuntimePermissions.Permission externalStorage = AndroidRuntimePermissions.RequestPermission("android.permission.WRITE_EXTERNAL_STORAGE");
            //AndroidRuntimePermissions.Permission camera = AndroidRuntimePermissions.RequestPermission("android.permission.CAMERA");
            //if (camera == AndroidRuntimePermissions.Permission.Granted && camera == AndroidRuntimePermissions.Permission.Granted)
            //    Debug.Log("We have permission to access external storage!");

            //Requesting WRITE_EXTERNAL_STORAGE and CAMERA permissions simultaneously
            AndroidRuntimePermissions.Permission[] result = AndroidRuntimePermissions.RequestPermissions("android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.CAMERA");
            if (result[0] == AndroidRuntimePermissions.Permission.Granted && result[1] == AndroidRuntimePermissions.Permission.Granted)
            {
                isPermission = true;
                Debug.Log("KAUEL: permission(s) are granted");
            }
            else
            {
                Debug.Log("KAUEL: Some permission(s) are not granted...");
            }


            if (!Permission.HasUserAuthorizedPermission(Permission.Camera))
            {
                Permission.RequestUserPermission(Permission.Camera);
                Debug.Log("KAUEL: Request Permission");
                Scene scene = SceneManager.GetActiveScene(); SceneManager.LoadScene(scene.name);
            }
            else
            {
                Debug.Log("KAUEL: Permission granted");
            }

            isPermission2 = true;
        }
#endif
#if PLATFORM_ANDROID
        if (!isPermission2)
        {
            if (!Permission.HasUserAuthorizedPermission(Permission.Camera))
            {
                Permission.RequestUserPermission(Permission.Camera);
                Debug.Log("KAUEL: Request Permission");
                Scene scene = SceneManager.GetActiveScene(); SceneManager.LoadScene(scene.name);
            }
            else
            {
                Debug.Log("KAUEL: Permission granted");
            }

            isPermission2 = true;
        }
#endif
    }
Exemplo n.º 5
0
    // Use this for initialization
    void Start()
    {
        isloading = true;
        Debug.Log(filePath);

        AndroidRuntimePermissions.Permission[] result = AndroidRuntimePermissions.RequestPermissions(WRITE_EXTERNAL_STORAGE, CAMERA, ACCESS_FINE_LOCATION);

        for (int i = 0; i < result.Length; i++)
        {
            if (result[i] == AndroidRuntimePermissions.Permission.Granted)
            {
                Debug.Log("We have all the permissions!");
            }
            else
            {
                Debug.Log("Some permission are not granted...");
            }
        }
    }
    void Awake()
    {
        Init();

        AndroidRuntimePermissions.Permission[] result = AndroidRuntimePermissions.RequestPermissions("android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.CAMERA");
        if (result[0] == AndroidRuntimePermissions.Permission.Granted && result[1] == AndroidRuntimePermissions.Permission.Granted)
        {
            Debug.Log("We have all the permissions!");
        }
        else
        {
            Debug.Log("Some permission(s) are not granted...");
        }

        cameraBackgroundBehaviour = FindObjectOfType <CameraBackgroundBehaviour>();
        if (cameraBackgroundBehaviour == null)
        {
            Debug.LogError("Can't find CameraBackgroundBehaviour.");
            return;
        }
    }