Answer the question
In order to leave comments, you need to log in
Pop-ups not appearing on Android in Unity, how to fix?
I'm making a game in Unity and I need access to the files, but as you know, I have to get permission to do so. I'm trying to request it from the user through the code, but the pop-up window with the request (these often pop up in various android applications) simply does not appear.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Android;
public class Perm : MonoBehaviour
{
readonly string[] _permissions = {Permission.ExternalStorageRead, Permission.ExternalStorageWrite};
// Start is called before the first frame update
void Awake()
{
#if UNITY_ANDROID
Permission.RequestUserPermission(Permission.ExternalStorageRead);
#endif
RequestPermission();
StartCoroutine(FckIt());
}
public void RequestPermission()
{
if (!Permission.HasUserAuthorizedPermission(Permission.ExternalStorageRead))
Permission.RequestUserPermissions(_permissions);
}
IEnumerator FckIt()
{
yield return new WaitForSeconds(10f);
RequestPermission();
}
}
Answer the question
In order to leave comments, you need to log in
After a long search, I found a solution. In order to solve this problem, you need to register all the necessary permissions in the AndroidManifest.xml file. Then at the start there will be a request, and a proposal will appear to allow the use of files
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question