You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Im using your example code and its working amazing on the simulator, but when I build it on my Device no image is shown.
It asks for permision and I give permission. I access my galley and choose a picture. ( Meanwhile a message is shown saying I will only be able to access the chosen images. When I choose one and select Add. A loading window appears for a milisec, but no image is shown.
The code;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
using UnityEngine.UI;
public class FilePickerSystem : MonoBehaviour
{
private string myFileType;
string myPath;
private Sprite mySprite;
public GameObject imagen;
void Start()
{
myFileType = NativeFilePicker.ConvertExtensionToFileType("jpg");
Debug.Log("pdf's MIME/UTI is: " + myFileType);
}
void Update()
{
if (Input.GetMouseButtonDown(0))
{
// Don't attempt to import/export files if the file picker is already open
if (NativeFilePicker.IsFilePickerBusy())
return;
if (Input.touchCount > 0)
{
NativeFilePicker.Permission permission = NativeFilePicker.PickFile((path) =>
{
if (path == null)
Debug.Log("Operation cancelled");
else
Debug.Log("Android Picked file: " + path);
myPath = path;
StartCoroutine( ChangeImage());
}, new string[] { myFileType });
Debug.Log("Permission result: " + permission);
}
}
}
IEnumerator ChangeImage()
{
WWW www = new WWW(myPath);
while (!www.isDone)
{
Debug.Log("null");
yield return 0;
}
Debug.Log(www.text);
mySprite = Sprite.Create(www.texture, new Rect(0.0f, 0.0f, www.texture.width, www.texture.height), new Vector2(0.5f, 0.5f), 100.0f);
imagen.GetComponent<Image>().sprite = mySprite;
}
}
Unity version: 2021.3.0f1*
Platform: . Android
Device: XIAOMI Redmi Note 11
Android Version: 11 RKQ1.211001.001
How did you download the plugin: GitHub, 4 days ago - Latest version
Activity
nataliapoppe9 commentedon Dec 14, 2023
I already Changed Player Settings to Write permission SD Card
yasirkula commentedon Dec 14, 2023
Can you try
WWW www = new WWW("file://" + myPath);? Also I'd strongly recommend NativeGallery instead.