videokit-ai / natshare

Cross-platform social sharing for Unity Engine.
https://github.com/natmlx/videokit
Apache License 2.0
134 stars 28 forks source link

Saved image on iOS not found #79

Closed ziadpower closed 4 years ago

ziadpower commented 4 years ago

Hi

I'm using Unity 2019.2.10f Xcode 11.3.1 iOS 13.3.1

To save an image (Texture2D) to the camera roll on my iPad and I get a confirmation for completion but I can't find the image in my photo gallery.

I've added both permissions on my XCode: NSPhotoLibraryUsageDescription NSPhotoLibraryAddUsageDescription

Here's the script:

public void Save(Texture2D img)
    {
        path = Application.platform == RuntimePlatform.Android ? Application.persistentDataPath : Application.streamingAssetsPath;
        string imagePath = Path.Combine(path,"image.png");        
        using (var payload = new SavePayload(null,OnSaveCompleted ))
        {
            payload.AddImage(img);
            payload.AddMedia(imagePath);
        }        
    }

    void OnSaveCompleted()
    {
        result.text="Image saved at\n "+path;
    }
olokobayusuf commented 4 years ago

The first thing to check is that your Texture2D is readable, in other words, if it has pixel data resident in system memory (in addition to graphics memory). Beyond that check the logs for any clues.