VR device used on Pico
When I use the VR eye Pico device, the message "No application can perform this operation" is displayed. Have you ever encountered similar problems?
May I see how you're invoking NativeGallery in your code?
I directly use the case to get pictures and videos.
public void PickImage(int maxSize)
{
NativeGallery.Permission permission = NativeGallery.GetImageFromGallery((path) =>
{
Debug.Log("Image path: " + path);
if (path != null)
{
// Create Texture from selected image
Texture2D texture = NativeGallery.LoadImageAtPath(path, maxSize);
if (texture == null)
{
Debug.Log("Couldn't load texture from " + path);
return;
}
// Assign texture to a temporary quad and destroy it after 5 seconds
GameObject quad = GameObject.CreatePrimitive(PrimitiveType.Quad);
quad.transform.position = Camera.main.transform.position + Camera.main.transform.forward * 2.5f;
quad.transform.forward = Camera.main.transform.forward;
quad.transform.localScale = new Vector3(1f, texture.height / (float)texture.width, 1f);
Material material = quad.GetComponent<Renderer>().material;
if (!material.shader.isSupported) // happens when Standard shader is not included in the build
material.shader = Shader.Find("Legacy Shaders/Diffuse");
material.mainTexture = texture;
Destroy(quad, 5f);
// If a procedural texture is not destroyed manually,
// it will only be freed after a scene change
Destroy(texture, 5f);
}
});
Debug.Log("Permission result: " + permission);
}
May I see how you're invoking NativeGallery in your code?
I see Log print "Permission result: Granted", "Image path"
Can you try this solution: https://github.com/yasirkula/UnityNativeGallery/issues/243#issuecomment-1229413732
Can you try this solution: #243 (comment)
Thank you very much! This solution can solve the current problem, I have another problem and I want to choose another file format (obj, fbx,...). If I directly add a file type to C# code, does aar support it?
May I see how you're invoking NativeGallery in your code?
I think in addition to video, picture, audio this three formats, there should be a custom file suffix type so that it is more convenient.
For other file formats you can use NativeFilePicker. However, you still can't filter obj and fbx files on Android with that plugin (see the documentation). But you can allow picking all files. After user picks a file, you can check its extension in C#.
对于其他文件格式,您可以使用 NativeFilePicker。但是,您仍然无法使用该插件在 Android 上过滤 obj 和 fbx 文件(请参阅文档)。但是您可以允许选择所有文件。用户选择文件后,您可以在 C# 中检查其扩展名。
I'm using GetMixedMediaFromGallery and I added a new enumeration to MediaType, which didn't get success and I don't know why? Only images or videos can be selected
对于其他文件格式,您可以使用 NativeFilePicker。但是,您仍然无法使用该插件在 Android 上过滤 obj 和 fbx 文件(请参阅文档)。但是您可以允许选择所有文件。用户选择文件后,您可以在 C# 中检查其扩展名。
What should I write if I want the user to select all the files and then filter them myself?
对于其他文件格式,您可以使用 NativeFilePicker。但是,您仍然无法使用该插件在 Android 上过滤 obj 和 fbx 文件(请参阅文档)。但是您可以允许选择所有文件。用户选择文件后,您可以在 C# 中检查其扩展名。
如果我希望用户选择所有文件,然后自己过滤它们,我应该写什么?
What I'm transmitting directly here is MediaType (int). What 0 should I pass in?
对于其他文件格式,您可以使用 NativeFilePicker。但是,您仍然无法使用该插件在 Android 上过滤 obj 和 fbx 文件(请参阅文档)。但是您可以允许选择所有文件。用户选择文件后,您可以在 C# 中检查其扩展名。
Oh, I see. I just reviewed the code and let the user select all the files. Thank you very much!
The mediaType parameter is passed to the native Android code and you'd have to modify it and recompile it in Android Studio to make it work. In the end, it wouldn't be different from NativeFilePicker so good choice.