Closed SashelI closed 1 year ago
Is this png file downloaded by your app? If you copy an arbitrary png file from your computer to Downloads, can it be seen by SimpleFileBrowser? BTW are/were any Storage permission dialogs displayed while opening the file browser?
Is this png file downloaded by your app? If you copy an arbitrary png file from your computer to Downloads, can it be seen by SimpleFileBrowser? BTW are/were any Storage permission dialogs displayed while opening the file browser?
Yup the png was copied from my computer, as were the .glb and the .json :) Nope no storage permission dialogue, well no more I accepted everything it asked once
If you log contents of Directory.GetFiles("/storage/emulated/0/Download") in your own C# script, does it contain the GLB and JSON files? And does removing MANAGE_EXTERNAL_STORAGE permission somehow have any effect?
If you log contents of Directory.GetFiles("/storage/emulated/0/Download") in your own C# script, does it contain the GLB and JSON files? And does removing MANAGE_EXTERNAL_STORAGE permission somehow have any effect?
Hey, I just tested, Logging Directory.GetFiles("/storage/emulated/0/Download") from my script only shows one file (the png) and the MANAGE_EXTERNAL_STORAGE permission is indeed useless in this, I added it afterwards in hopes of making it work but nah ^^"
I think we need to figure out why Directory.GetFiles fails in the first place. Since it's a built-in .NET function, this issue isn't directly caused by SimpleFileBrowser. If the Directory.GetFiles issue can be resolved somehow, then I believe SimpleFileBrowser will work without any issues.
For the time being, I don't have time to research this. If you find useful resources related to this issue in your own research, please let me know.
Ok thanks. I've tried to find that out before asking here and found nothing, i'll keep on looking.
For anyone running into the same issue : it was caused by the "MANAGE_EXTERNAL_STORAGE permission" not being taken into account if you don't explicitely ask for it in the app, even if you accepted every other external storage auth.
I had to add
using var buildCodes = new AndroidJavaClass("android.os.Build$VERSION_CODES");
//Check SDK version > 29
if (buildVersion.GetStatic<int>("SDK_INT") > buildCodes.GetStatic<int>("Q"))
{
using var environment = new AndroidJavaClass("android.os.Environment");
//сhecking if permission already exists
if (!environment.CallStatic<bool>("isExternalStorageManager"))
{
using var settings = new AndroidJavaClass("android.provider.Settings");
using var uri = new AndroidJavaClass("android.net.Uri");
using var unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
using var currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
using var parsedUri = uri.CallStatic<AndroidJavaObject>("parse", $"package:{Application.identifier}");
using var intent = new AndroidJavaObject("android.content.Intent",
settings.GetStatic<string>("ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION"),
parsedUri);
currentActivity.Call("startActivity", intent);
}
}
From here before calling the FileBrowser, and now I can see every file in the folder -_- I had rejected the "not enough permission" theory as I could see the png in the folder, but I guess Android auths are really f*ked up above Android 11...
Mind that it can throw a warning when publishing your app in the store with this permission in the manifest.
Anyway, thanks
Thank you for sharing your solution! I'll add a link to it from FAQ. I wish NativeFilePicker worked with Quest which wouldn't have this issue but unfortunately AFAIK it doesn't, so your solution is the only way to go at the moment.
Thanks. Yeah I've tried native file picker before this one, and quickly realized the Android 12 + Meta combo will be a nightmare to figure out x)
The known Quest issue is, file picker's result is allegedly not sent to the device until the app is minimized and then maximized. If that wasn't an issue, I think it would work wonderfully.
Description of the bug
Hi,
Thanks for the asset ! It works well on the Quest Pro (Android), but I've got a problem : .glb and .json files are not appearing in the browser, nor listed by system.IO when retrieving directory info. It works well in the editor when removing the "!Unity_Editor" preprocessing for testing, but once inside the quest the files are non existent. (but png files in the same folder are here).
I've tried using Directory.GetFiles(path) instead of GetFileSystemInfo, but same. The "show hidden files" button doesn't help, and there is no log message.
Reproduction steps
Platform specs
Additional info
Manisfest File : `<?xml version="1.0" encoding="utf-8" standalone="no"?>