Hello, I am using the Native Gallery plugins to bring an image of the android gallery up to here everything works fine but it is happening to me. that when I change the texture2d in a sprite, I do not load the new image on the button and if I remove the previous one I had. Then I leave the code to see if you can help me. thank you and sorry for my english that is not very good.
GameObject newObj;
private 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;
}
Destroy(newObj.GetComponent<Image> ());
Sprite newSprite = Sprite.Create(texture, new Rect(0,0,1024,1024), new Vector2(0.5f,0.5f));
newObj.GetComponent<Image>().sprite = newSprite;
}
}, "Select a PNG image", "image/png", maxSize );
Debug.Log( "Permission result: " + permission );
}