// Use this for initialization
    void Start()
    {
//		PermissionGranterUnity.GrantPermission(WRITE_INTERNAL_STORAGE, PermissionGrantedCallback);
        PermissionGranterUnity.GrantPermissions(new string[] { WRITE_INTERNAL_STORAGE, READ_INTERNAL_STORAGE,
                                                               WRITE_EXTERNAL_STORAGE, READ_EXTERNAL_STORAGE,
                                                               CAMERA }, PermissionGrantedCallback);
//		PermissionGranterUnity.GrantPermissions(new string[] {WRITE_INTERNAL_STORAGE, READ_INTERNAL_STORAGE}, PermissionGranterUnity.PermissionRequestCallback);
//		PermissionGranterUnity.GrantPermission(READ_INTERNAL_STORAGE, PermissionGranterUnity.PermissionRequestCallback);
//		PermissionGranterUnity.GrantPermission (WRITE_EXTERNAL_STORAGE, PermissionGranterUnity.PermissionRequestCallback);
    }
Beispiel #2
0
            public void Awake()
            {
                // instance is also set in initialize.
                // having it here ensures this thing doesn't break
                // if you added this component to the scene manually
                instance = this;
                DontDestroyOnLoad(this.gameObject);

                // object name must match UnitySendMessage call in native side
                if (name != PERMISSION_GRANTER_GAMEOBJECT_NAME)
                {
                    name = PERMISSION_GRANTER_GAMEOBJECT_NAME;
                }
            }
Beispiel #3
0
    public void OnCamAuthClick()
    {
        if (Application.platform != RuntimePlatform.WindowsEditor)
        {
#if UNITY_ANDROID
            Debug.Log("camera is " + PermissionGranterUnity.IsPermissionGranted("android.permission.CAMERA"));
            StartCoroutine(startCamera());
            //Debug.Log("start Permission granted:");
            //PermissionGranterUnity.GrantPermission("android.permission.CAMERA", PermissionGrantedCallback);
#endif
        }
        else
        {
            cameraAuthed = 1;
            PlayerPrefs.SetInt("cameraauth", cameraAuthed);
        }
    }
Beispiel #4
0
            private static void initialize()
            {
                // runs once when you call GrantPermission

                // add object to scene
                if (instance == null)
                {
                    GameObject go = new GameObject();
                    // instance will also be set in awake, but having it here as well seems extra safe
                    instance = go.AddComponent <PermissionGranterUnity>();
                    // object name must match UnitySendMessage call in native side
                    go.name = PERMISSION_GRANTER_GAMEOBJECT_NAME;
                }

                // get the jni stuff. we need the activity class and the PermissionGranterUnity class.
                AndroidJavaClass unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer");

                currentActivity   = unity.GetStatic <AndroidJavaObject>("currentActivity");
                permissionGranter = new AndroidJavaObject("com.partagames.unity.permissiongranter.unity.PermissionGranterUnity");

                initialized = true;
            }
 public void GrantMultiplePerm()
 {
     PermissionGranterUnity.GrantPermissions(new string[] { WRITE_EXTERNAL_STORAGE, CAMERA }, PermissionGrantedCallback);
 }
 public void GrantCamera()
 {
     PermissionGranterUnity.GrantPermission(CAMERA, PermissionGrantedCallback);
 }
 public void GrantStorage()
 {
     PermissionGranterUnity.GrantPermission(WRITE_EXTERNAL_STORAGE, PermissionGrantedCallback);
 }
 public void CheckCamera()
 {
     text.text += "\nCheck permission: CAMERA" + ": " + (PermissionGranterUnity.IsPermissionGranted(CAMERA) ? "Yes" : "No");
 }
 public void CheckStorage()
 {
     text.text += "\nCheck permission: WRITE_EXTERNAL_STORAGE" + ": " + (PermissionGranterUnity.IsPermissionGranted(WRITE_EXTERNAL_STORAGE) ? "Yes" : "No");
 }
 public void CheckShouldShowRequestPermissionRationale()
 {
     text.text += "\n Should show request permission rationale: " + PermissionGranterUnity.ShouldShowRequestPermissionRationale(WRITE_EXTERNAL_STORAGE);
 }